while loop average grade program **PLZ HELP**

Create a program to continually input grades from the user. Exit the loop when the user types a grade less than 0. Then tell the user how many grades he entered (eg. "You entered 5 grades") and calculate and report the average of the grades. Make sure it doesn't include the negative number!

heres what i got so far: I need it to calculate the average of the grades the user inputs, then output it. But i am having trouble doing that.

#include <iostream>
#include <string.h>
using namespace std;
int main()

int grades;
int count;
float avg;
float sum;
do {

cout<<"Enter a grade\n";

}while (grades>!0);

cout<<"You enterd"<<" "<<count <<" "<<"grades";

if (count)
{ avg = sum / count;


cout<<"The average of the grades is "<<avg;

return 0;
Last edited on
Please note that this is not a homework site. We won't do your homework for you. The purpose of homework is that you learn by doing. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.

We didn't see your attempts to solve this problem yourself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again.
Topic archived. No new replies allowed.