c++

posted by .

write a program that reads ten numbers, computes their average and find out how many numbers are above average.

  • c++ -

    Since 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

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. c++

    write a program that reads ten numbers, computes their average and find out how many numbers are above average.
  2. Programming

    I suppose to write a program that calculates the average of up to 50 numbers input by the user and stored in an array. The program should use a class name Statistics and have an AddNumber method that stores numbers into an arrey one …
  3. Programming

    I need your help to write a program using visual basic 2010 for the following:- write a program that calculates the average of up to 50 numbers input by the user and stored in an arrey. The program should use a class named Statistics …
  4. Programming

    Here is the question that I need help to write the code for the following program in Visual Basic 2010. I am trying to write the code but it has a run time error. If your could helps me to write the code it would be greatly appreciated. …
  5. MATH

    WRITE A SIMPLE BUT A COMPLETE FORTRAN PROGRAM TO COMPUTE THE AVERAGE OF SIX NUMBERS AND DISPLAY THE NUMBERS, SUM AND AVVERAGE. THE PROGRAM SHOULD TERMINATE WHEN ZERO IS ENTERED AS A NUMBER. THE PROGRAM SHOULD BE EDUCATIVE
  6. Programming

    Read two numbers from the keyboard Display the menu options as follows: 1 - computes the sum of two numbers. 2 - computes the difference (first minus second). 3 - computes the product of the two numbers. 4 - if the second number is …
  7. computer

    Write an algorithm for a program that accepts a set of numbers and finds the smallest among them and computes the sum of the numbers accepted. The program stops when the user enters number 999. Convert the algorithm into flowchart
  8. computer science

    Write a java program that reads from the user the course code, section and the scores of a student for three exams representing two midterms and a final. The percentage of each of the three exams is of fixed value 30, 30 and 40 percent …
  9. programming

    Example Develop a pseudocode algorithm for a program that accepts each of the average marks of 10 students in a class and computes the sum and the average mark of the class. The program should display the average mark of the class. …
  10. computer programming

    Design the logic for a program that allows a user to enter any amount of numbers up to 10 or until a sentinal value of -1 is entered. Then the program displays the count of the numbers entered and numeric average of the numbers (not …

More Similar Questions