You are here:

# C++/I need help with a C program please.

Question
I'm a complete newbie to C programming and I need help writing a program. The program should do the following:

Prompt the user to select the number of grades he wishes to average.  Max points for each grade are 100.  Calculate the Average grade of all of the grades entered and display the final Average, the lowest and highest grades entered. This program should use a WHILE loop in its main loop.

Example program output:

How many grades do you wish to average: 5

============================================

The average of the grades was 76.24

The highest grade entered was 100.00

The lowest grade entered was  43.25

============================================

So far I just have a program that will let me sum all the grades up, but I don't know how to make it sum as many grades as the user wishes and average them. I know that when the user is prompted to enter the number of grades he wishes to average, the total sum should be divided by whatever number the user entered. The program I've written to sum is as follows and the program for averaging grades should follow the same format such as using only #include<stdio.h> and int main():

#include <stdio.h>
int main(void)
{
long num;
long sum = 0L;
int status;

printf("Please enter an integer to be summed ";
printf("(q to quit): ");
status = scanf("%ld", &num);
while (status == 1)
{
sum = sum + num;
printf("Please enter next integer (q to quit): ");
status = scanf(%ld", &num);
}
printf("Those integers sum to %ld. \n", sum);
return 0
}

Any help you could offer would be much appreciated. You would be really helping me out and I would be sure to rate you highly for however little help that you can offer me.

Thanks again,
Samantha

You are almost there.
Here is an outline of what you should do:

#include <stdio.h>

int main(void)
{
int number_entered_so_far = 0 ;

/*
1. prompt the user to enter the number of grades
to be processed by the program
*/

{
/*
1. prompt the user to enter a grade
*/

++number_entered_so_far ;

}

/*
*/
return 0 ;
}

>  I would be sure to rate you highly for however little help that you can offer me.
I strongly encourage you to rate the answers honestly based on your evaluation of their merit. A high rating by itself means little to me unless I know it is genuine. And it might mislead others who use the site.

C++

Volunteer

#### vijayan

##### Expertise

my primary areas of interest are generic and template metaprogramming, STL, algorithms, design patterns and c++11. i would not answer questions about gui and web programming.