Patterns
in C++
Introduction
● To understand the loops more decently we need to do patterns so that we can
have the better understanding of the loops. Without practising patterns the
loops are incomplete.
● Patterns are very important to master the loops.
● Patterns are not asked in interview but they plays a vital role in DSA so
everyone should
Rules for patterns
1. For the outer loop, Count the number of lines
2. For the inner loops, Focus on the columns and connect them somehow to the
rows
3. Print them ‘*’ inside the inner for loop.
4. Observe symmetry [optional].
Pattern 1
****
****
****
****
To take the input from the
user
Pattern 2
***
***
****
*****
Pattern 3
1
1 2
1 23
1 234
1 2345
Pattern 4
1
2 2
3 33
4 444
5 5555
Pattern 5
*****
****
***
**
*
Pattern 6
1 2345
1 234
1 23
1 2
1
Pattern 7
*
***
*****
*******
*********
Pattern 8
*********
*******
*****
***
*
Pattern 9
*
***
*****
*******
*********
*********
*******
*****
***
*
Pattern 10
Homework Questions