Hi i made this program and i am only doing c++ a tiny while.Code:#include <iostream> #include <iomanip> int main() { int total, gradeCounter, grade; float average; total = 0; gradeCounter = 0; cout << "Enter grade, -1 to end: "; cin >> grade; while (grade != -1 ) { total = total + grade; gradeCounter = gradeCounter + 1; cout << "Enter grade, -1 to end: "; cin << grade; } if ( gradeCounter != 0 ) { average = static_cast< float >( total ) cout << "Class average is " << setprecision( 2 ) << setiosflags ( ios::fixed | ios::showpoint ) << average << endl; } else cout <<"No grades were entered" <<endl; return 0; }
I am compiling on gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
Thanks alot guys/girls
I hope to be a regular.



LinkBack URL
About LinkBacks


