write a program to diaplay a pyramid as shown:

The following output is obtained:


    1

   212

  32123

 4321234

543212345

543212345

 4321234

  32123

   212

    1



Select To use this code as it is.. select and copy paste this code into code.cpp file :)



  1. #include <iostream.h>
  2. #include <conio.h>
  3. void main()
  4. {
  5. clrscr();
  6. for (int i=1;i<=5;i++)
  7. {
  8. for(int j=4;j>=i;j--)
  9. cout<<" ";
  10. for(int k=1;k<=i;k++)
  11. cout<<k;
  12. for(k=i-1;k>=1;k--)
  13. cout<<k;
  14. cout<<"\n";
  15. }
  16. for (i=5;i>=1;i--)
  17. {
  18. for(int j=4;j>=i;j--)
  19. //Coding by: Snehil Khanor
  20. //http://WapCPP.blogspot.com
  21. cout<<" ";
  22. for(int k=1;k<=i;k++)
  23. cout<<k;
  24. for(k=i-1;k>=1;k--)
  25. cout<<k;
  26. cout<<"\n";
  27. }
  28. getch();
  29. }

Check out this stream