Thread: Calculating the average, high, and low for each quiz and display them

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    1

    Calculating the average, high, and low for each quiz and display them

    I am having trouble writing a code that always a person to enter 5 grades for 5 students. I am using arrays to do this, but I cannot calculate the average out right and getting the high and low numbers to display across the screen. I would like to get some tips thanks!

  2. #2
    Registered User
    Join Date
    Sep 2009
    Posts
    61
    A good tip:
    Show us the code...

  3. #3
    Registered User
    Join Date
    Aug 2004
    Location
    San Diego, CA
    Posts
    313
    Well, think about it logically. If you've got an array, say grades[5], what do you know about C and arrays that will make walking it a little easier? (Think pointers!) As for calculating the high and low, can you sort the array so you know that, for example, grades[0] is the lowest and grades[4] is the highest? Or maybe keep track of it with other variables as you walk through the array to add up the grades so you can calculate the average? - I'm just trying to give you a couple ideas to get your brain working, but there's an amazing number of ways to do what you want to do. Try it and see what happens, and if it doesn't work, try it a different way.

    Also: if it helps, write down the steps on a piece of paper and go from there.

Popular pages Recent additions subscribe to a feed