1: //square_integers.cpp 2: //Displays a table of integer squares. 3: //Illustrates a count-controlled while-loop. 5: #include <iostream> 6: #include <iomanip> 7: using namespace std; 9: int main() 10: { 11: cout << "\nThis program displays a table of integer squares from 1\n" 12: "up to a maximum value chosen by the user.\n\n"; 14: int numberOfSquares; 16: cout << "Enter the maximum value to be included in the table: "; 17: cin >> numberOfSquares; cin.ignore(80, '\n'); 19: cout << "\n\n n n * n" << endl; 21: int n = 1; 22: while (n <= numberOfSquares) 23: { 24: cout << setw(4) << n << setw(10) << n * n << endl; 25: ++n; 26: } 27: cout << endl; 28: }