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++

how to find that the given number is a palindrome


This is the source code to find that the given number is palindrome or not........

#include<iostream.h>
#include<conio.h>
main()
{
      int number,a,b,c,d,e,f,g,h,mango;
      cout<<"Ente the five digit number:";
      cin>>number;
      cout<<endl;
      mango=number/10000;
      a=number%10000;
      b=a/1000;
      c=a%1000;
      d=c/100;
      e=c%100;
      f=e/10;
      g=e%10;
      cout<<mango<<b<<d<<f<<g<<endl;
      if(mango==g && b==f)
      cout<<"number is palindrom";
      else
      cout<<"number is not a palindrom";
      getch();
}
End