Interactive while Loops, read value inside while loop - C++ Statement

C++ examples for Statement:while

Description

Interactive while Loops, read value inside while loop

Demo Code

#include <iostream>
#include <iomanip>
using namespace std;
int main()//from  www. j a  va 2  s  .  com
{
   const int MAXNUMS = 4;
   int count;
   double num;
   cout << "\nThis program will ask you to enter "
   << MAXNUMS << " numbers.\n";
   count = 1;
   while (count <= MAXNUMS)
   {
      cout << "\nEnter a number: ";
      cin  >> num;
      cout << "The number entered is " << num;
      count++;
   }
   cout << endl;
   return 0;
}

Result


Related Tutorials