I'm beginner C++ and I need so help. I started but, i think i might doing it wrong.
Write a program that prints a pattern follow:
Prompt the user for a number between 1 and 10.
Do not accept numbers greater than 10 or less than 0.
Keep prompting the user for a value until a 0 is entered.
If a 0 is entered, then quit the program.
int size ; // the size of the square to be printed
do // Keep prompting the user for a value
// Prompt the user for a number between 1 and 10.
// Do not accept numbers greater than 10 or less than 0.
// keep repeating the loop till a valid number is entered
// (or input fails: say, the user enters a letter instead of a number)
while( std::cout << "enter number of rows between 1 and 10 (enter 0 to quit): " &&
std::cin >> size && size < 0 || size > 10 ) ;
// print the pattern (note: this doesn't print anything if size == 0 and we should quit)
for( int row = 0 ; row < size ; ++row ) // print 'size' number of rows
// in each row print 'size' number of asterisks
for( int col = 0 ; col < size ; ++col ) std::cout << '*' ;
std::cout << '\n' ;
while( size != 0 ) ; // until a 0 is entered, when we quit the program.