Thread: dont know whats wrong

  1. #1
    Student otchster's Avatar
    Join Date
    Oct 2005
    Posts
    30

    dont know whats wrong

    i think this program is right, but i cant figure out why its not working.

    Code:
    
    #include <stdio.h>
    #define SIZE 10
    double number[ SIZE ];
    
     int main()
    {
    int count, square;
       for (count = 0; count < SIZE; count++)
       {
       printf("enter one of the ten real numbers %d: ", count );
       scanf("%lf", &number[ count ] );
       }
    printf("list of the numbers square.\n");
       for ( count = 0; count < SIZE; count++ )
       {
       square = %lf * %lf;
       printf(" number[ %d ] = %lf\n", count, square );
       }
       return (0);

  2. #2
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    I can figure out why it's not working.

    Did you look at your compiler errors?
    Code:
    square = %lf * %lf;
    The above is nonsense. What are you actually supposed to be squaring there?

    Also, if you are prompting for real numbers, why is square an int?

    Also, you forgot the closing brace.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    I think
    Code:
    square = %lf * %lf;
    was supposed to be
    Code:
    square = count * count;
    or
    Code:
    square = number[count] * number[count];
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 07-15-2004, 03:30 PM
  2. Debugging-Looking in the wrong places
    By JaWiB in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 11-03-2003, 10:50 PM
  3. Confused: What is wrong with void??
    By Machewy in forum C++ Programming
    Replies: 19
    Last Post: 04-15-2003, 12:40 PM
  4. God
    By datainjector in forum A Brief History of Cprogramming.com
    Replies: 746
    Last Post: 12-22-2002, 12:01 PM
  5. Whats wrong?
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 07-14-2002, 01:04 PM