1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
| #include <graphics.h>
#include <math.h>
#include <iostream.h>
#include <conio.h>
void otherSpoints(int x, int y,int xc,int yc)
{
putpixel(-x+xc,y+yc,WHITE);
putpixel(x+xc,-y+yc,WHITE);
putpixel(-x+xc,-y+yc,WHITE);
putpixel(y+xc,x+yc,WHITE);
putpixel(-y+xc,x+yc,WHITE);
putpixel(y+xc,-x+yc,WHITE);
putpixel(-y+xc,-x+yc,WHITE);
}
void CIRCLE(int r)
{
int x,y;
int xc=getmaxx()/2;
int yc=getmaxy()/2;
// Plotting the First Point
x=0;
y=r;
putpixel(xc+x,yc+y,WHITE);
// Other Symmetry points:
otherSpoints(x,y,xc,yc);
//Initializing Decision Variable
int d=3-2*r;
//Plotting Other Points of Circle
while(x<y)
{
if(d<0)
{
d=d+4*x+6;
x+=1;
}
else
{
d=d+4*(x-y)+10;
x+=1;
y-=1;
}
putpixel(x+xc,y+yc,WHITE); otherSpoints(x,y,xc,yc);
} //end of while
} //end of function
void main()
{
int gdriver=DETECT, gmode;
initgraph(&gdriver, &gmode, "C:/TC/BGI");
setbkcolor(DARKGRAY);
setcolor(WHITE);
int r;
cout<<"\n Enter the radius: ";
cin>>r;
cout<<"\n Press Enter to draw Circle.";
getch();
CIRCLE(r);
getch();
closegraph();
} |