C++ while statement read value inside while loop

Description

C++ while statement read value inside while loop

#include <iostream>
#include <iomanip>
using namespace std;
int main()//w w w. j a v  a 2s. c o m
{
   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;
}



PreviousNext

Related