VOOZH about

URL: https://www.geeksforgeeks.org/cpp/cpp-program-to-print-pyramid-patterns/

⇱ C++ Program To Print Pyramid Patterns - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C++ Program To Print Pyramid Patterns

Last Updated : 23 Jul, 2025

In this article, we will discuss the following top 16 pattern programs in C++ using star ( * ), numbers or other characters.

👁 Cpp-Pattern-Programs

C++ Programs to Print Patterns and Pyramids

Creating patterns is a fun way to practice your C++ skills. The C++ Course includes hands-on examples and exercises for printing various patterns, helping you enhance your problem-solving abilities. Here are some of the most common patterns with their logic.

1. Simple Pyramid Pattern in C++

Method 1:

Printing simple pyramid pattern using for loop


Output
* 
* * 
* * * 
* * * * 
* * * * * 

Time Complexity: O(n2), where n is the input number of rows.
Auxiliary Space: O(1),

Method 2:

Printing the above pattern using while Loop


Output
* 
* * 
* * * 
* * * * 
* * * * * 

Method 3:

Printing the above pattern using recursion.


Output
* 
* * 
* * * 
* * * * 
* * * * * 

2. Flipped Simple Pyramid Pattern in C++

Method 1:

Printing the 180° rotated simple pyramid pattern using for loop.


Output
 * 
 * * 
 * * * 
 * * * * 
* * * * * 

Method 2:

Printing the above pattern using while loop.


Output
 * 
 * * 
 * * * 
 * * * * 
* * * * * 

3. Inverted Pyramid Pattern in C++

Method 1:

Printing the pattern using for loop.


Output
* * * * * 
* * * * 
* * * 
* * 
* 

Method 2:

Printing the pattern using while loop.


Output
* * * * * 
* * * * 
* * * 
* * 
* 

Method 3:

Printing the above pattern using recursion.


Output
* * * * * 
* * * * 
* * * 
* * 
* 

4. Flipped Inverted Pyramid Pattern in C++

Method 1:

Printing this pattern using for loop.


Output
* * * * * 
 * * * * 
 * * * 
 * * 
 * 


Method 2: Printing the above pattern using while loop.


Output
* * * * * 
 * * * * 
 * * * 
 * * 
 * 

5. Triangle Pattern in C++

Method 1:

Printing the given pattern using for loop.


Output
 * 
 * * 
 * * * 
 * * * * 
* * * * * 

Method 2:

Printing the above pattern using while loop.


Output
 * 
 * * 
 * * * 
 * * * * 
* * * * * 

6. Inverted Triangle Pattern in C++

Method 1:

Printing the inverted triangle pattern using for loop.


Output
* * * * * * * * * 
 * * * * * * * 
 * * * * * 
 * * * 
 * 

Method 2:

Printing the above pattern using while loop.


Output
* * * * * * * * * 
 * * * * * * * 
 * * * * * 
 * * * 
 * 

7. Half Diamond Pattern in C++


Output
* 
* * 
* * * 
* * * * 
* * * * * 
* * * * 
* * * 
* * 
* 

8. Flipped Half Diamond Pattern in C++


Output
 *
 **
 ***
 ****
*****
 ****
 ***
 **
 *

9. Diamond Shaped Pattern in C++


Output
 *
 ***
 *****
 *******
*********
 *******
 *****
 ***
 *

10. Hourglass Pattern in C++


Output
* * * * * * * * * 
 * * * * * * * 
 * * * * * 
 * * * 
 * 
 * * * 
 * * * * * 
 * * * * * * * 
* * * * * * * * * 

11. Number Pyramid Pattern in C++

Method 1:

Printing the number pyramid pattern using for loop.


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

Method 2:

Printing the above pattern using while loop.


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

12. Numbers Pyramid Pattern without Reassigning in C++

Method 1

Printing the number pyramid pattern in C++ without reassigning using for loop.


Output
1 
2 3 
4 5 6 
7 8 9 10 
11 12 13 14 15 

Method 2:

Printing the above pattern using while loop.


Output
1 
2 3 
4 5 6 
7 8 9 10 
11 12 13 14 15 

13. Continuous Number Pyramid after 180° Rotation in C++


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

14. Palindrome Triangle Pattern in C++


Output
 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 

15. Alphabet Pyramid Pattern in C++

Method 1:

Printing the given pattern using for loop.


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

Method 2:

Printing the above pattern using while loop.


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

16. Continuous Alphabet Pyramid Pattern in C++

Method 1:

Printing the above pattern using for loop.


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

Method 2:

Printing the above pattern using while loop.


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


Printing patterns in python language are discussed in the following article - Programs for printing pyramid patterns in Python


Comment