C program while loop...help

August 18, 2010 at 00:47:09
Specs: Windows XP
Write a program using a while loop that will ask the user the following
Enter how many numbers you would like to add > 3
Please enter the 1 number> 24
Please enter the 2 number> 55
Please enter the 3 number > 100

The total of 3 numbers = 179

Your program should consist of comments to the program and a snapshot of the output.

See More: C program while loop...help

Report •

August 18, 2010 at 02:20:45
$150 an hour for homework questions, everything else is free.

You learn by working these things out for yourself, not by asking other to do it for you.


Report •

August 18, 2010 at 11:10:45
First and foremost, you should always read in numbers using a string and then convert it using the appropriate function, or at least test the input stream.

For your program

int start = 0, stop, sum = 0, input,

// prompt for user's total numbers (stop variable)
while(start < stop) {
   // ask for each number to sum
   // validate the number
      // if valid sum += input; stop++;
      // if bad, clear the input stream, and alert the user

// output the sum

Report •
Related Solutions

Ask Question