Thursday

March 26, 2015

March 26, 2015

Posted by **nethiyaa** on Tuesday, May 10, 2011 at 2:27am.

- c++ -
**MathMate**, Tuesday, May 10, 2011 at 7:13amSince one of the requirements is to find out how many are above average, and there are only 10 numbers, it would be a good idea to store the numbers in an array so you would not have to read the numbers a second time.

Reading it more than once is not a good idea because we never know if the file has changed in the mean time.

You also have to know if the numbers are integers (int), or are they real numbers (double or float).

Eventually, the average will have to be a double or float using type cast.

Here's a possible pseudocode. Work on the coding, and post if you have further questions.

// start

Declare array of 10 numbers, num.

Declare variable sum, initialize to zero.

Declare numVar, initialize to 10.

Declare mean, initialize to zero.

Declare count, initialize to zero.

Read input numbers into array num.

// calculations

for i=0 to numVar-1

{

sum ← sum + num[i]

}

mean ← ((double)sum)/numVar

count=0

for i=0 to numVar-1

{

if num[i]>mean then

{

count ← count + 1

}

}

// output

Print numVar, mean, count

**Answer this Question**

**Related Questions**

c++ - write a program that reads ten numbers, computes their average and find ...

Programming - I need your help to write a program using visual basic 2010 for ...

Programming - I suppose to write a program that calculates the average of up to ...

Programming - Here is the question that I need help to write the code for the ...

Programming - Read two numbers from the keyboard Display the menu options as ...

MATH - WRITE A SIMPLE BUT A COMPLETE FORTRAN PROGRAM TO COMPUTE THE AVERAGE OF ...

Math - The average of the first 4 numbers is 14. The average of the next 6 ...

Math - The average of 3 numbers is 45. If one of the numbers is 43, what is the ...

math - 10 numbers have an average of 12 whereas 5 other numbers have an average ...

Math - The average of 7 numbers is 30. the average of the first to the fourth ...