C++ while statement to print a table of numbers from 1 to 10 with the numbers' squares and cubes

Description

C++ while statement to print a table of numbers from 1 to 10 with the numbers' squares and cubes

#include <iostream>
#include <iomanip>
using namespace std;
int main()//from  w w  w.  ja  v a2s . co  m
{
   int num;
   cout << "NUMBER    SQUARE    CUBE\n" << "------    ------    ----\n";
   num = 1;
   while (num < 11)
   {
      cout << setw(3) << num << "        " << setw(3) << num * num << "      " << setw(4) << num * num * num << endl;
      num++;         // increment num
   }
   return 0;
}



PreviousNext

Related