An example of a program to average these values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • damatrix1
    New Member
    • Sep 2007
    • 1

    An example of a program to average these values

    28, 32,37,24,33 im not sure how to make the program calculate it
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    Originally posted by damatrix1
    28, 32,37,24,33 im not sure how to make the program calculate it
    How would you do this by hand if you were just given a sheet of paper with those numbers on it?

    Comment

    • mattmao
      New Member
      • Aug 2007
      • 121

      #3
      This little program needs only one line of code inside the main() method, which is a printf statement that tells you the avg value of these numbers.

      You know perform the calculation of the average value, don't you?

      Comment

      • annagloria
        New Member
        • Oct 2007
        • 1

        #4
        good day.
        i ask the example of average of 5 input number.

        Comment

        • mohaakilla51
          New Member
          • Jul 2007
          • 39

          #5
          we can't actually put the code out there for you...(in case it is school related)

          but here would be your algorithm
          1.)Ask user to input the variables(optio nal)
          2.)calculate the sum of the variables: sum = var1+var2+var3+ var4+var5
          3.)divide them by the number of variables: avg = sum/5
          4.) Output the avg to the screen: cout << avg

          see that? I just gave you at least of half of how to do it, all you have to do know is initialize the variables, and step 1 (possibly)

          Comment

          Working...