Search This Blog

Sunday, 15 September 2013

Print Pyramid through C++

Pyramid in C++

#include<iostream.h>
#include<conio.h>

main()
{
   int a,b,i,temp;
   cout<<"Enter the level of pyramid:";
   cin>>a;
   temp=a;
   for(i=1;i<=a;i++)
   {
      for(b=1;b<=temp;b++)
      cout<<" ";
      temp--;
      for(b=1;b<=2*i-1;b++)
      cout<<"*";
      cout<<endl;
   }
   getch();
} 

Output 

No comments:

Popular Posts