First time here? Checkout the FAQ!
x
menu search
brightness_auto
more_vert

Write a program To implement Midpoint circle

thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike

1 Answer

more_vert
 
verified
Best answer
#include<stdio.h>
#include<graphics.h>
#include<math.h>
void main()
{
float p;
int i,gd,gm,x,y;
int r; 
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"\\tc\\bgi");
 
printf("Enter the radius of the circle :");
scanf("%d",&r);

x=0;
y=r;
p = 1.25 - r;
do
{
putpixel(200+x,200+y,15);
putpixel(200+y,200+x,15);
putpixel(200+x,200-y,15);
putpixel(200+y,200-x,15);
putpixel(200-x,200-y,15);

putpixel(200-x,200+y,15);
putpixel(200-y,200+x,15);
putpixel(200-y,200-x,15);

if (p < 0)
{
x = x+1;
y = y;
p = p + 2*x + 1;
}
else
{
x= x+1;
y= y-1;
p = p + 2*(x-y) + 1;
}
delay(100);
}
while(x < y);
getch();
closegraph();
}
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
...