My photo
Bangalore, Karnataka, India
Extending one hand to help someone has more value rather than joining two hands for prayer

Archives

print diamond

Tuesday, September 1, 2009

#include<iostream.h>
#include<conio.h>
void main()
{
int i,j,k;
clrscr();
for(i=1;i<=15;i++){
for(j=i;j<15;j++)
cout<<" ";
k=2*i-1;
while(k>=1){
cout<<"*";
k--;
}
cout<<" ";
}
for(i=14;i>=1;i--){
for(j=i;j<15;j++)
cout<<" ";
k=2*i-1;
while(k>=1)
{
cout<<"*";
k--;
}
cout<<" ";
}
getch();
}

1 comments:

Jaspreet Singh Batth said...

Hey I've run Your diamond printing program, its not working. Plz add '\n' after the end of both major for-loops. I'll work then. Thanks for this blog Upinder.