# C program to implement Bresenham Circle Drawing Algorithm

Complete C program to implement Bresenham’s Circle Drawing Algorithm

# include<stdio.h>
# include<conio.h>
# include <graphics.h>
# include<math.h>
#include<dos.h>
/* Function for plotting the co-ordinates at four different angles that are placed
at egual distences */
void plotpoints(int xcentre, int ycentre,int x,int y)
{
int color=5;
putpixel(xcentre+x,ycevtre+y,color);
putpixel(xcentre+x,ycevtre-y,color);
putpixel(xcentre-x,ycevtre+y,color);
putpixel(xcentre-x,ycevtre-y,color);
putpixel(xcentre+y,ycevtre+x,color);
putpixel(xcentre+y,ycevtre-x,color);
putpixel(xcentre-x,ycevtre+x,color);
putpixel(xcentre-y,ycevtre-x,color);
}
/* Function for calculating the new points for(x,y)co-ordinates. */
void cir(int xcentre, ycentre, int radius)
{
int x,y,p;
plotpoints(xcentre,ycentre,x,y);
while(x<y)
{
if(p<0)
p=p+2*x+1:
else

{
y--;
p=p+2*(x-y)+1;
}
x++;
plotpoints xcentre, ycentre,x,y);
delay(100);
}
}
/* The main function that takes (x,y) and ‘r’ the radius from keyboard and
activates other functions for drawing the circle */
void main()
{
intgd=DETECT,gm,xcentre=200,ycentre=150,redius=5;
printf(“\n enter the center points and radius :\n”);