C++ examples for Statement:for
Use for loops to print a table of numbers from 1 to 10, including their squares and cubes
#include <iostream> #include <iomanip> using namespace std; int main()//w w w . j a v a 2s . c o 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; }