Data is accepted continuously until a number larger than 100 is entered. - C++ Language Basics

C++ examples for Language Basics:Console

Description

Data is accepted continuously until a number larger than 100 is entered.

Demo Code

#include <iostream>
using namespace std;
int main()/* w  ww  .  j av  a  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;
}

Result


Related Tutorials