Use 2 nested loops

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.


#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <string>

using namespace std;
int main()
{

int num = 0;


cout << "Welcome to the Asterisk Pattern Program \n";
cout << " \n";

cout << "Enter max number of asterisks (1 - 10. 0 to quit) : \n";
for (int row = 1; row <= 3; row++)
{
for (int col = 1; col <= row; col++)
{
cout << "*" << "\t";

}
cout << endl;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>

int main()
{
    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.
}
Registered users can post here. Sign in or register to post.