#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd = DETECT, gm;
int x1,y1=0,di,limit=0,R,d,d1,xi,yi;
clrscr();
initgraph(&gd, &gm,"C:\TC\BGI");
xi=getmaxx()/2;
yi=getmaxy()/2;
setcolor(2);
setbkcolor(8);
printf("\n\n Enter the radius :");
scanf("%d",&R);
line(0,yi,xi*2,yi);
line(xi,0,xi,yi*2);
x1=-R;
di=2*(1-R);
putpixel(xi,yi,RED);
while(x1<=limit)
{
putpixel(xi+x1,yi-y1,RED);
delay(75);
if(di<0)
{
d=(2*di)-(2*y1)-1;
if(d<=0)
{
y1=y1-1;
di=di-2*y1+1;
}
else
{
x1=x1+1;
y1=y1-1;
di=di+2*x1-2*y1+2;
}
}
else
{
if(di>0)
{
d1=2*di-2*x1-1;
if(d1<=0)
{
x1=x1+1;
y1=y1-1;
di=di+2*x1-2*y1+2;
}
else
{
x1=x1+1;
di=di+2*x1+1;
}
}
else
{
if(di==0)
{
x1=x1+1;
y1=y1-1;
di=di+2*x1-2*y1+2;
}
}
}
}
getch();
closegraph();
}
#include<conio.h>
#include<graphics.h>
void main()
{
int gd = DETECT, gm;
int x1,y1=0,di,limit=0,R,d,d1,xi,yi;
clrscr();
initgraph(&gd, &gm,"C:\TC\BGI");
xi=getmaxx()/2;
yi=getmaxy()/2;
setcolor(2);
setbkcolor(8);
printf("\n\n Enter the radius :");
scanf("%d",&R);
line(0,yi,xi*2,yi);
line(xi,0,xi,yi*2);
x1=-R;
di=2*(1-R);
putpixel(xi,yi,RED);
while(x1<=limit)
{
putpixel(xi+x1,yi-y1,RED);
delay(75);
if(di<0)
{
d=(2*di)-(2*y1)-1;
if(d<=0)
{
y1=y1-1;
di=di-2*y1+1;
}
else
{
x1=x1+1;
y1=y1-1;
di=di+2*x1-2*y1+2;
}
}
else
{
if(di>0)
{
d1=2*di-2*x1-1;
if(d1<=0)
{
x1=x1+1;
y1=y1-1;
di=di+2*x1-2*y1+2;
}
else
{
x1=x1+1;
di=di+2*x1+1;
}
}
else
{
if(di==0)
{
x1=x1+1;
y1=y1-1;
di=di+2*x1-2*y1+2;
}
}
}
}
getch();
closegraph();
}
Sign up here with your email
ConversionConversion EmoticonEmoticon