#include<graphics.h>
#include<stdio.h>
#include<conio.h>
void plotcircle(int,int,int,int);
void main()
{
int gd = DETECT, gm;
int xc,yc,x,y,r,d;
initgraph(&gd, &gm, "");
printf("\n Enter the values\n xc:\nyc:\nr:\n");
scanf("%d%d%d",&xc,&yc,&r);
x=0;
y=r;
d=3-(2*r);
plotcircle(xc,yc,x,y);
while(x<y)
{
if(d<0)
{
x=x+1;
d=d+(4*x)+6;
}
else
{
x=x+1;
y=y-1;
d=d+(4*(x-y))+10;
}
plotcircle(xc,yc,x,y);
}
getch();
}
void plotcircle(int xc,int yc,int x,int y)
{
putpixel(xc+x,yc+y,2);
putpixel(xc-x,yc+y,2);
putpixel(xc+x,yc-y,2);
putpixel(xc+y,yc+x,2);
putpixel(xc-y,yc-x,2);
putpixel(xc-y,yc+x,2);
putpixel(xc+y,yc-x,2);
putpixel(xc-x,yc-y,2);
}
No comments:
Post a Comment