-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBresenhemCDA.cpp
More file actions
45 lines (44 loc) · 817 Bytes
/
BresenhemCDA.cpp
File metadata and controls
45 lines (44 loc) · 817 Bytes
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
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
{
int gd=DETECT,gm;
int d,r,x,y,xc,yc;
initgraph(&gd,&gm,"");
printf("Enter the radius:");
scanf("%d",&r);
printf("Enter the center of circle:");
scanf("%d%d",&xc,&yc);
d=3-2*r;
x=0;
y=r;
printf("NAME: ANANYA SHARMA\n SAPID: 500077736\n");
printf("The points are:\n");
while(x<=y)
{
putpixel(x+xc,y+yc,WHITE);
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);
printf("(%d, %d)\n",x,y);
if(d<=0)
{
d=d+4*x+6;
x++;
}
else
{
d=d+4*x-4*y+10;
y=y-1;
x++;
}
}
getch();
closegraph();
return 0;
}