Clarify this please?

I got no idea what does this suppose to mean. When I read the details on the book, I'm like O.O what... lol So here.
1
2
3
4
5
if ( gradeCounter != 0 ) {
        average = static_cast < double > (total) / gradeCounter; 
        cout << "Class average is " << setprecision( 2 ) 
            << setiosflags ( ios::fixed | ios::showpoint )
            << average << endl;
Last edited on
if gradeCounter is not equal to 0 then the variable total is casted(converted) into type double and divided by the variable gradeCounter and stored in the variable average .Then average is printed and the stream manipulators control how.

the setprecision() sets the decimal precision.
You can read about the setiosflags here:
http://www.cplusplus.com/reference/iostream/manipulators/setiosflags/
.
Topic archived. No new replies allowed.