c++ Diamond Code
#include<iostream.h>
#include<conio.h>
main()
{
clrscr();
int x=19;
int y=5;
for(int i=1;i<=5;i++)
{
gotoxy(x,y);
for(int j=1;j<=i;j++)
cout<<"* ";
x--;
y++;
cout<<endl;
}
int a=16;
int b=10;
for(int c=5;c>1;c--)
{
gotoxy(a,b);
for(int d=c;d>1;d--)
cout<<"* ";
a++;
b++;
cout<<endl;
}
getch();
return 0;
}
#include<conio.h>
main()
{
clrscr();
int x=19;
int y=5;
for(int i=1;i<=5;i++)
{
gotoxy(x,y);
for(int j=1;j<=i;j++)
cout<<"* ";
x--;
y++;
cout<<endl;
}
int a=16;
int b=10;
for(int c=5;c>1;c--)
{
gotoxy(a,b);
for(int d=c;d>1;d--)
cout<<"* ";
a++;
b++;
cout<<endl;
}
getch();
return 0;
}
No comments: