20 Easy Patterns and Shapes in C++: Star, Pyramid, Triangles

Here I’ve shared various star, triangle, pyramids patterns and shapes in C++ using asterisks, numbers, alphabets etc. These are simple program which require basic programming knowledge.

Examples to print half pyramid, pyramid, inverted pyramid, Pascal’s Triangle and Floyd’s triangle in C++ Programming using control statements.

Printing these patterns is not easy if you don’t have basic idea of using different loops, once you get a basic idea of these pattern programs shared below, you can make any pattern or shape instantly. Hope you find these useful and keep commenting for the new patterns and shapes you want me to upload for everyone’s help.

Patterns and shapes

Following are the various Patterns and shapes in C++:

1. C++ Program To display the half pyramid of *, numbers and character.

*
* *
* * *
* * * *
* * * * *

 

2. C++ Program to print half pyramid as using numbers as shown in figure below.

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

 

3. C++ Program to print triangle of characters as below:

A
B B
C C C
D D D D
E E E E E

 

4. C++ Program to print inverted half pyramid using * as shown below:

* * * * *
* * * *
* * *
* *
*

 

5. C++ Program to print inverted half pyramid as using numbers as shown below.

1 2 3 4 5
1 2 3 4
1 2 3
1 2
1

 

6. C++ Program To display the pyramid of * and digits.

        *
      * * *
    * * * * *
  * * * * * * *
* * * * * * * * *

 

7. C++ program to print the pyramid of digits in pattern as below.

        1
      2 3 2
    3 4 5 4 3
  4 5 6 7 6 5 4
5 6 7 8 9 8 7 6 5

8. C++ program to draw isosceles triangle using alphabets EDCBA

        A 
      C B A 
    E D C B A 
  G F E D C B A
I H G F E D C B A

9. C++ program to display reverse pyramid.

* * * * * * * * *
  * * * * * * *
    * * * * *
      * * *
        *

10. C++ Program to Draw Pascal’s triangle as below.

           1
         1   1
       1   2   1
     1   3   3    1
   1  4    6   4   1
 1  5   10   10  5   1

11. C++ Program to display Floyd’s Triangle.

1
2 3
4 5 6
7 8 9 10

12. C++ Program to draw inverted hollow triangle.

* * * * * * *
 *         *
   *     *
     * *
      *

13.  C++ Program to display following pattern:

A
B C
D E F
G H I J
K L M N O

Above were some common patterns and shapes and now we will discuss another list of patterns and shapes which are asked in various Interviews.

14. C++ program to print inverted right triangle using * as below:

* * * * *
  * * * * 
    * * *
      * *
        *

15. C++ program to print square pattern using * as below:

* * * * *
* * * * *
* * * * *
* * * * *
* * * * *

16. C++ program to print square pattern using numbers as below:

1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5

17. C++ program to print square pattern as below:

1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5

18. C++ program to print square pattern as below:

A A A A A
B B B B B
C C C C C
D D D D D
E E E E E

19. C++ program to print square pattern as below:

5 4 3 2 1
5 4 3 2 1
5 4 3 2 1
5 4 3 2 1
5 4 3 2 1

 

20. C++ program to below pattern:

*
*
*
* * * * * * *
*
*
*

Keep asking for new patterns and shapes in C++, I’ll keep adding them to the list, also comment in case you find any issue with patterns and shapes.