0% found this document useful (0 votes)
51 views14 pages

Patterns Notes

The document discusses patterns in C++ and provides rules and examples for creating different patterns using loops. The rules are to use an outer loop to control the number of lines and inner loops to control the columns, connecting them to rows and printing "*" inside the inner loop. It then provides 10 examples of patterns produced by loops, ranging from simple straight and diagonal lines to triangular shapes.

Uploaded by

cheatcode
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views14 pages

Patterns Notes

The document discusses patterns in C++ and provides rules and examples for creating different patterns using loops. The rules are to use an outer loop to control the number of lines and inner loops to control the columns, connecting them to rows and printing "*" inside the inner loop. It then provides 10 examples of patterns produced by loops, ranging from simple straight and diagonal lines to triangular shapes.

Uploaded by

cheatcode
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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

You might also like