/*MID POINT CIRCLE DRAWING*/
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
void main()
{
int gdriver = DETECT,gmode,x,y,r,x1,y1;
float e;
initgraph(&gdriver,&gmode,"C:\\tc\\BGI");
printf("center co-ordinate of x and y position of circle:\n");
scanf("%d %d",&x,&y);
printf("input the radius of circle:\n");
scanf("%d",&r);
x1=0;
y1=r;
putpixel(x+0,y+r,RED);
putpixel(x+r,y+0,RED);
putpixel(x-0,y-r,RED);
putpixel(x-r,y-0,RED);
e=1.25-r;
while(x1<y1)
{
if(e<0)
{
x1=x1+1;
e=e+2*x1+3;
}
else
{
x1=x1+1;
y1=y1-1;
e=e+4*(x1-y1)+5;
}
putpixel(x+x1,y+y1,1);
putpixel(x+y1,y+x1,2);
putpixel(x-x1,y+y1,3);
putpixel(x-y1,y+x1,4);
putpixel(x-x1,y-y1,5);
putpixel(x-y1,y-x1,6);
putpixel(x+x1,y-y1,7);
putpixel(x+y1,y-x1,8);
delay(100);
}
getch();
}
/*NOTE:-You have to change the graphics driver location according to your compiler graphics file address which has been written in initgraph in quotation. */
No comments:
Post a Comment