Pyramid Patterns in C++ with Examples
Master C++ with Real-time Projects and Kickstart Your Career Start Now!!
Program 1
// Star Pyramid Program
#include<iostream>
#define clrscr() system("cls")
using namespace std;
int main()
{
int n,m;
int i,j,k;
cout<<"\n Enter the limit of row";
cin>>n;
m=n;
for(i=1;i<=n;i++)
{
for(j=1;j<=m-1;j++)
{
cout<<" ";
}
for(k=1;k<=2*i-1;k++)
{
cout<<"*";
}
m--;
cout<<"\n";
}
}Program 2
// Star Pyramid Program1
#include<iostream>
#define clrscr() system("cls")
using namespace std;
int main()
{
int n,m;
int i,j,k;
cout<<"\n Enter the limit of row";
cin>>n;
m=n;
for(i=n;i>=1;i--)
{
for(j=1;j<m;j++)
{
cout<<" ";
}
for(k=1;k<=2*i-1;k++)
{
cout<<"*";
}
m++;
cout<<"\n";
}
} Did you know we work 24x7 to provide you best tutorials
Please encourage us - write a review on Google

