actually i dont know how i got it right the first time when i used your code, but now it's not working
this is my code:
#include<iostream.h>
int main()
{
int clas;
int grades;
int number;
int score;
int avg;
int time;
int student;
int total;
cout<<"enter the # of students in the class";
cin>>clas;
cout<<"enter the # of grades for the class";
cin>>grades;
for (student=1; student<=clas; student++)
{
cout<<"enter test grades for student #";
cin>>number;
cout<<"enter -1 for absent"<<endl;
for (time=1; time<=grades; time++)
{
cout<<"\t test #"<<time;
cin>>score;
total+=score; // here's the mistake, it doesnt total it correctly
if (score==-1)
{
score=0;
}
}
avg=total/(grades-1);
avg=total/grades;
cout<<"the avg of student #"<<number<<"is"<<avg<<endl;
}
return 0;
}
when it shows me the average it gives me a big number, the code seems right i dont know what's wrong with that little part, if you have any suggestions post them please... thx