/* Works on XP */
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void pt(int,int);
int xc,yc,r;
void main()
{
int gm,gd=DETECT,x=0,y,d;
clrscr();
initgraph(&gd,&gm,"c:\\tc\\bgi"); /*Sometimes it may be "C:\\TC\\BGI" , It depends machine to mac..*/
printf("Enter the center x and y ");
scanf("%d%d",&xc,&yc);
printf("Enter the radius ");
scanf("%d",&r);
y=r;
d=3-2*r;
while(x<=y)
{
pt(x,y);
if(d<0)
d=d+4*x+6;
else
{d=d+4*(x-y)+10;
y--;
}
x++;
}
getch();
closegraph();
}
void pt(int x,int y)
{putpixel(x+xc,y+yc,4);
putpixel(y+xc,x+yc,4);
putpixel(-x+xc,y+yc,4);
putpixel(-y+xc,x+yc,4);
putpixel(-y+xc,-x+yc,4);
putpixel(-x+xc,-y+yc,4);
putpixel(x+xc,-y+yc,4);
putpixel(y+xc,-x+yc,4);
}
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void pt(int,int);
int xc,yc,r;
void main()
{
int gm,gd=DETECT,x=0,y,d;
clrscr();
initgraph(&gd,&gm,"c:\\tc\\bgi"); /*Sometimes it may be "C:\\TC\\BGI" , It depends machine to mac..*/
printf("Enter the center x and y ");
scanf("%d%d",&xc,&yc);
printf("Enter the radius ");
scanf("%d",&r);
y=r;
d=3-2*r;
while(x<=y)
{
pt(x,y);
if(d<0)
d=d+4*x+6;
else
{d=d+4*(x-y)+10;
y--;
}
x++;
}
getch();
closegraph();
}
void pt(int x,int y)
{putpixel(x+xc,y+yc,4);
putpixel(y+xc,x+yc,4);
putpixel(-x+xc,y+yc,4);
putpixel(-y+xc,x+yc,4);
putpixel(-y+xc,-x+yc,4);
putpixel(-x+xc,-y+yc,4);
putpixel(x+xc,-y+yc,4);
putpixel(y+xc,-x+yc,4);
}