Find us on Google+ Kill the code: Mid-Point Circle program in C

Wednesday, 8 February 2012

Mid-Point Circle program in C



#include<conio.h>
#include<stdio.h>
#include<graphics.h>
void main()
{
int xc, yc, x=0, y, i=0, gd=DETECT, gm, p[20];
clrscr();
initgraph(&gd, &gm, "c:\\tc\\bgi");
printf("enter the center of the circle : ");
scanf("%d",&xc);
scanf("%d",&yc);
printf("enter the radius : ");
scanf("%d",&y);
p[0]=1-y;
putpixel(xc+x,yc+y,100);
putpixel(xc+x,yc-y,100);
putpixel(xc+y,yc+x,100);
putpixel(xc+y,yc-x,100);
putpixel(xc-x,yc+y,100);
putpixel(xc-x,yc-y,100);
putpixel(xc-y,yc+x,100);
putpixel(xc-y,yc-x,100);



while(x<=y)
{
if(p[i]<0)
{
p[i+1]=p[i]+2*x+1;
x=x+1;
i++;
}
else
{
p[i+1]=p[i]+2*x-2*y+1;
x=x+1;
y=y-1;
i++;
}
putpixel(xc+x,yc+y,100);
putpixel(xc-x,yc+y,100);
putpixel(xc+x,yc-y,100);
putpixel(xc-x,yc-y,100);
putpixel(xc+y,yc+x,100);
putpixel(xc+y,yc-x,100);
putpixel(xc-y,yc+x,100);
putpixel(xc-y,yc-x,100);
}
getch();
closegraph();
}

2 comments:

  1. ur to ou bg wf vn iw fe in pc hi st wo hf ou gp hi st wo hf ou gp hi st nt wh ou gp hi st nt wh ou gp hi st ea ri yo ub rc wf vo ub wt eo ps pc hi st wo hf ou bu eh wo hf ou gp hi st nt wh ou bu eh nt wh ou ga...


    somebody...guyz..can help me open it this code...
    pleeeaaassseee....:o

    ReplyDelete
  2. I didn't get you..can you explain what you actually want to do with the code...

    ReplyDelete