// program to print all the squares from 1 to the entered number #include using namespace std; int main() { int number; int counter; int square; cout << "Enter a positive number -- "; cin >> number; // using a while loop counter = 1; while (counter <= number) { square = counter * counter; cout << square << ' '; counter = counter + 1; } cout << endl; // using a do-while loop counter = 1; do { if (counter <= number) { square = counter * counter; cout << square << ' '; counter = counter + 1; } } while (counter <= number); cout << endl; // using a for loop for(counter = 1; counter <= number; counter++) { square = counter * counter; cout << square << ' '; } cout << endl; return 0; }