Please always use code tags:
www.cplusplus.com/articles/z13hAqkS/
Also:
total = (grade1 + grade2 + grade3 + grade4) / 4;
That is doing integer division, probably not what you want.
double total = (grade1 + grade2 + grade3 + grade4) /
4.0;
The
4.0 forces the promotion to double. I always put digits before and after the decimal place for doubles, it prevents these type of errors. Remove the first time you have that statement: you don't have the data yet.
This:
1 2
|
int grade1;
grade1 = 0;
|
Is more efficiently written as:
int grade1 = 0; // declaration and assignment in one statement.
Generally one can wait until there is a sensible value before doing declaration and assignment.
verdantgale wrote: |
---|
Don't forget return 0; |
that isn't actually required in C++, but there is no harm in having it anyway.
Using
std::vector
is a good idea, learn C++ , not C.
The
continue
statement is used in a loop, not an
if
statement. It means start the loop again, so it makes no sense in an
if
statement.
With the cout , always read the documentation about things you are not sure about.
Good Luck !!