0 votes
91 views
in Computer Graphics by (98.9k points)
retagged by
Write a program To implement Midpoint circle

1 Answer

0 votes
by (98.9k points)
selected by
 
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();
}

Related questions

0 votes
1 answer 104 views
0 votes
1 answer 101 views

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

557 users

...