This is my code for drawing a circle using mid point algorithm:-

```
//Midpoint circle algorithm
#include<graphics.h>
#include<stdio.h>
#include<conio.h>
void drawcircle(int xc,int yc,int r);
int main()
{
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"..//bgi");
drawcircle(250,250,10);
getch();
return 0;
}
void drawcircle(int xc,int yc,int r)
{
int p,x=0,y=r,incr1=2*x+3,incr2=incr1+2-2*y;
void drawPixel(int,int,int,int);
drawPixel(xc,yc,x,y);
p=1-r;
while(x<=y)
{
if(p<0)
{
p+=incr1;
x+=1;
}
else
{
p+=incr2;
y-=1;
x+=1;
}
drawPixel(xc,yc,x,y);
}
}
void drawPixel(int xc,int yc,int x,int y)
{
putpixel(xc+x,yc+y,RED);
putpixel(xc+x,yc-y,RED);
putpixel(xc-x,yc+y,RED);
putpixel(xc-x,yc-y,RED);
putpixel(xc+y,yc+x,RED);
putpixel(xc+y,yc-x,RED);
putpixel(xc-y,yc+x,RED);
putpixel(xc-y,yc-x,RED);
}
```

The program compiles and runs but produces a distorted square like image in the output..no way near to the circle.. I am using Turbo C compiler.Please help me identify the error. I am following "Computer Graphics" Hearn and Baker book for the program.