C++ for statement loop print a table of numbers from 1 to 10, for their squares and cubes

Description

C++ for statement loop print a table of numbers from 1 to 10, for their squares and cubes

#include <iostream>
#include <iomanip>
using namespace std;
int main()// w  w w . jav  a 2s. co  m
{
   const int MAXNUMS = 10;
   int num;
   cout << "NUMBER    SQUARE    CUBE\n" << "------    ------    ----\n";
   for (num = 1; num <= MAXNUMS; num++)
      cout << setw(3) << num << "        " << setw(3) << num * num << "      " << setw(4) << num * num * num << endl;
   return 0;
}



PreviousNext

Related