You can write the code as follows:
char question = 'y' // small y
int number;
while ( question == 'y' )
{
cout << "Enter a number to be squared: ";
cin >> number;
cout << "Square of " << number << " is " << number * number << endl;
cout << "Do you want to enter another number ? Type ( y/n): "; // n or
any char will come out of while loop
cin >> question;
}
|