-
homework help Please!
- Write a program that a prof can use to enter the test marks of several students and which calculates the average mark of each student. Ask the user how many students he has, then ask him to enter each student's marks. When 999 is entered, calculate the average mark for that student (not counting the 999) and print the average. Then go on to the next students until the marks for all students have been entered, calculated and the average printed.
Code:
#include<stdio.h>
main()
{
float student,mark,total=0;
float a,b,c;
int num = 999;
printf("\nPlease enter how many students you have: " );
scanf("%f",&student);
do {
printf("\nPlease enter each student's marks: ");
scanf("%f",&mark);
total = total + mark;
} while(mark!=num);
a = total - 999;
b = a / (student*100);
c = b * 100;
printf("\nThe average is %.2f%%.",c);
getch();
}
Could you please give some suggestion about this program?
-
Use meaningful variable names.
Indent the code so it is easy to follow.
This should be a constant and better named; and the use it instead of 999!
Tim S.
-
You might try actually reading the homework question more closely - it gives several clues about what you need to do, which you quite clearly have not acted on.
More generally, read this link.