# Circle drawing using Bresenhams Algorithm In c program | CS1355-Graphics & Multimedia Lab

Without using circle function in graphics draw the circle. By using Bresenhams Algorithm draw the circle.These Circle algorithm is a variant of Bresenham’s line algorithm.The algorithm begin with circle formula .
x(2)+y(2)=r(2),x(2) repersent x square..,
See the source code
Source code C Language programming
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
void cplot(int,int,int,int);
void main()
{
int gd=DETECT,gm;
int x,y,p,xc,yc,r;
initgraph(&gd,&gm,"");
cleardevice();
printf("x,y,r : ");
scanf("%d%d%d",&xc,&yc,&r);
x=0;y=r;
p=1-r;
cplot(xc,yc,x,y);
while(x<y)
{
x++;
if(p<0)
p+=2*x+1;
else
{
y--;
p+=2*(x-y)+1;
}
cplot(xc,yc,x,y);
}
getch();
}
void cplot(int xc,int yc,int x,int y)
{
putpixel(xc+x,yc+y,15);
putpixel(xc-x,yc+y,15);
putpixel(xc+x,yc-y,15);
putpixel(xc-x,yc-y,15);
putpixel(xc+y,yc+x,15);
putpixel(xc-y,yc+x,15);
putpixel(xc+y,yc-x,15);
putpixel(xc-y,yc-x,15);
}
//# Author: J.Ajai
//#Mail-id- ajay.compiler@gmail.com
//# PH:+91-9790402155

OUTPUT
Bresenhams Circle Drawing Algorithm
Enter the center point of the circle:
X = 100
Y = 200
R = 50