The program is as follows:
#include<stdio.h>
#include<graphics.h>
void bres(int xc,int yc,int r)
{
int p,k,x,y;
p=1-r;
x=0;
y=r;
for(k=0;k<=y;k++)
{
putpixel(xc+x,yc+y,5);
putpixel(xc-y,yc-x,5);
putpixel(xc+y,yc-x,5);
putpixel(xc-y,yc+x,5);
putpixel(xc+y,yc+x,5);
putpixel(xc-x,yc-y,5);
putpixel(xc+x,yc-y,5);
putpixel(xc-x,yc+y,5);
if(p>0)
{
p=p+2*(x+1)+1-2*(y+1);
x++;
y--;
}
else
{
p=p+2*(x+1)+1;
x++;
}
}
}
int main()
{
int gd=DETECT,gm;
int xc,yc,r;
printf("Enter the center and radius");
scanf("%d%d%d",&xc,&yc,&r);
initgraph(&gd,&gm,"..\\BGI\\");
bres(xc,yc,r);
delay(1500);
getch();
return 0;
}
No comments:
Post a Comment