Home » Unlabelled » C++ programme to print pyramid pattern
Saturday, 20 December 2014
C++ programme to print pyramid pattern
//This programme is tested on visual studio 2012//
#include<iostream>
using namespace std;
void main()
{
int n,t=1;
cout<<"------------------------------------------------------------------------------\n";
cout<<"This programme will print a pyramid pattern on entering number greater than 1\n";
cout<<"------------------------------------------------------------------------------\n";
cout<<"Enter number :- ";
cin>>n;
while (n<=1)
{
cout<<"You entered invalid input Try again :\n";
cout<<"Enter number";
cin>>n;
}
for(int i=1;i<=n;i++)
{
if(i==1)
{
for(int j=1;j<=n;j++)
{
cout<<" ";
}
cout<<"*"<<endl;
}
else
{
for(int z=i;z<=n;z++)
cout<<" ";
cout<<"*";
for(int k=i+1;k<t;k++)
cout<<" ";
cout<<"*"<<endl;
}
t=t+3;
}
cout<<"\n\n------------------------------------------------------------------------------\n";
cout<<"Thank You for using.\n\nVisit http://bilalzahid22.blogspot.com/ for more\n";
cout<<"\n------------------------------------------------------------------------------\n";
}
Lihat juga Artikel dari
Subscribe to:
Post Comments (Atom)


0 comments:
Post a Comment