for( a; b; c ) { body; }
matches (except area) as
a; while (b) { body; c; }
Do this for your code:
bool b_valid=false; while (b_valid = false) {
We do not need to go further. This is a task, not a comparison. It sets b_valid to false, and then checks to see if it is true. Since it never was, the cycle never starts.
But you really need a do / while :
bool b_valid; do { cin >> n_grade; if ( n_grade>100 || n_grade<0 ) { cout << "Invalid grade: Re-enter a number between 0-100 : " << endl;
The do-while loop always runs at least once.
source share