C++ while statement read data continuously until a number larger than 100 is entered

Description

C++ while statement read data continuously until a number larger than 100 is entered

#include <iostream>
using namespace std;
int main()//from  w  w w . j  a  va  2  s  .  c om
{
   const int HIGHGRADE = 100;
   double grade, total;
   grade = 0;
   total = 0;
   cout << "\nTo stop entering grades, type in any number\n greater than 100.\n\n";
   while (grade <= HIGHGRADE)
   {
      total = total + grade;
      cout << "Enter a grade: ";
      cin  >> grade;
   }
   cout << "\nThe total of the grades is " << total << endl;
   return 0;
}



PreviousNext

Related