My Blog

My WordPress Blog

My Blog

My WordPress Blog

Write a Program to Print a Simple Pyramid Pattern

C++// C++ Program to print a simple pyramid #include <iostream> using namespace std; int main() { int rows = 5; for (int i = 1; i <= rows; i++) { for (int j = rows; j >= i; j--) { cout << " "; } for (int k = 1; k <= (2 * i - 1); k++) { cout << "*"; } cout << endl; } return 0; }

Output

     *
***
***** ******* *********
Write a Program to Print a Simple Pyramid Pattern

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top