In this article, we are going to learn about how to Print Full Pyramid Pattern Programs in C++ language. First, we are going to print the full Pyramid pattern and then in the next program, we will print this Pyramid in the center of the screen.
- How to print Full Pyramid pattern using * in C++ language.
- How to print full Pyramid at Center of the screen using * in C++ language.
Desired Output for Size 5:
*
***
*****
*******
*********
1.How to Full Pyramid Pattern Programs in C++ language.
C++ program for the above full pyramid star pattern,
#include <iostream>
using namespace std;
int main()
{
int num, row, col;
cout<<"Please enter the number of rows: ";
cin>>num;
for(row = 1; row <= num; row++)
{
for(int s=1; s<=num-row; s++)
cout<<" ";
for(col = 1;col <= (2*row-1);col++)
cout<<"*";
cout<<"\n";
}
return 0;
}
Output
Please enter the number of rows: 7
*
***
*****
*******
*********
***********
*************
- C++ Program to print alphabets triangle from A to E
- C++ Program to print diamond pattern
- C++ Program to print triangle pattern
- Program to print pi pattern in C++
- Simple Pattern Program in C++
- Character Pattern using ASCII value in C++
- Diagonal pattern using Numbers in C++
- Upper Case Character Pattern in C++ using ASCII
- Upper lower Case Mix Character Pattern in C++
2.How to print full Pyramid at Center of screen using * in C++ language
In this example, we are going to learn how to print the full pyramid at the center of screen.In this example, we will assume that screen width is 100 character.Desired Output for Size 7:
*
***
*****
*******
*********
***********
*************
C++ Program to print a Full Pyramid Pattern
#include <iostream>
using namespace std;
int main()
{
int num,screensize=100;
cout<<"Please enter the number of rows: ";
cin>>num;
for(int i = 1; i <= num; i++)
{
for(int j = 1; j <= (screensize/2-i); j++)
{
cout<<" ";
}
for(int k = 1; k <= (2*i-1); k++)
{
cout<<"*";
}
cout<<"\n";
}
return 0;
}
Output
Please enter the number of rows: 7
*
***
*****
*******
*********
***********
*************