Quote:
|
now i want to improve it by limiting the user to take only digits from 0 - 9
|
Code:
while(cin >> size)
{
if(size < 0 || size > 9)
{
cout << "Sorry your given number isn't within acceted limits (0-9)" << endl;
continue;
}
...
Quote:
After the output is shown , there is a repsone taken from user
Press any key to exit
|
hmm... shouldn't this run untill the user explicit exit, or should it just be a single run ??
To accommodate a request running untill the user explicit exits, you would take percausions like
Code:
cout << "Please enter a number between 0 and 9, use -1 to quit: ";
while(cin >> size && size >= 0)
...
To accommodate the user unly beeing asked once, and then exit uppon further user interaction, just eliminate your while clause, and simply read from the user, check for valid number, and then print your pyramid.
Then query the user "press anythign to quit" and simply just let the program terminate uppon next linefeed.