Thursday 20 December 2012

how to make pyramid in c++

construct pyramid of x in c++
how to make pyramid in c++

construct pyramid of x in c++:- 

This is the source code to make pyramid from asterik using c++.....

#include<iostream>
#include<iomanip>
using namespace std;
main(){
       int u=1;
       int space;
       int i,x;
       cout<<"Enter the length of the pyramid:";
       cin>>x;
       while(u<=x)
       {
                  i=1;
                  cout<<setw(space);
                  while(i++<=u)
                  cout<<"X";
                  u=u+2;
                  space--;
                  cout<<endl;
                  }
       system("pause");          
       }
End

 And:
pyramid in c++
how to make pyramid in c++

No comments:

Post a Comment