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 :)
- #include <iostream.h>
- #include <conio.h>
- void main()
- {
- clrscr();
- for (int i=1;i<=5;i++)
- {
- for(int j=4;j>=i;j--)
- cout<<" ";
- for(int k=1;k<=i;k++)
- cout<<k;
- for(k=i-1;k>=1;k--)
- cout<<k;
- cout<<"\n";
- }
- for (i=5;i>=1;i--)
- {
- for(int j=4;j>=i;j--)
- //Coding by: Snehil Khanor
- //http://WapCPP.blogspot.com
- cout<<" ";
- for(int k=1;k<=i;k++)
- cout<<k;
- for(k=i-1;k>=1;k--)
- cout<<k;
- cout<<"\n";
- }
- getch();
- }
0 comments:
Post a Comment