C++ Program to Create Pyramid Pattern
Master C++ with Real-time Projects and Kickstart Your Career Start Now!!
Program 1
//Program to print star Pyramid
// *
// **
// ***
#include<iostream>
using namespace std;
int main()
{
int i,j,n;
system("cls");
cout<<"Enter the limit";
cin>>n;
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
cout<<"*";
}
cout<<"\n";
}
return 0;
}Program 2
//Program to print star Pyramid
// 1
// 22
// 333
//4444
#include<iostream>
using namespace std;
int main()
{
int i,j,n;
system("cls");
cout<<"Enter the limit";
cin>>n;
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
cout<<i;
}
cout<<"\n";
}
return 0;
}Program 3
//Program to print star Pyramid
// 1
// 12
// 123
//1234
#include<iostream>
using namespace std;
int main()
{
int i,j,n;
system("cls");
cout<<"Enter the limit";
cin>>n;
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
cout<<j;
}
cout<<"\n";
}
return 0;
}Program 4
//Program to print star Pyramid
// A
// AB
// ABC
//ABCD
#include<iostream>
using namespace std;
int main()
{
int i,j,n;
char ch;
system("cls");
xyz:cout<<"\nEnter the limit";
cin>>n;
if(n>26)
{
cout<<"\nPls Enter till 26";
goto xyz;
}
else
{
for(i=1;i<=n;i++)
{
ch='A';
for(j=1;j<=i;j++)
{
cout<<ch;
ch++;
}
cout<<"\n";
}
}
return 0;
}
We work very hard to provide you quality material
Could you take 15 seconds and share your happy experience on Google

