C++ program for Bresenham's circle drawing algorithm
codeaft.cpp
#include<graphics.h>
#include<iostream>usingnamespacestd;intmain(){floatd;intx,y,x1,y1,r,gd=0,gm;cout<<"Enter the x1 coordinate ";cin>>x1;cout<<"Enter the y1 coordinate ";cin>>y1;cout<<"Enter the radius of circle ";cin>>r;initgraph(&gd,&gm,NULL);x=0;y=r;d=(3-2)*r;do{putpixel(y1+x,x1+y,15);putpixel(x1+y,y1+x,15);putpixel(x1+y,y1-x,15);putpixel(y1+x,x1-y,15);putpixel(y1-x,x1-y,15);putpixel(x1-y,y1-x,15);putpixel(x1-y,y1+x,15);putpixel(y1-x,x1+y,15);if(d<=0){d=d+(4*x)+6;}else{d=d+4*(x-y)+10;y=y-1;}x=x+1;}while(x<y);delay(7000);return0;}
Output
codeaft@codeaft:~$ g++ codeaft.cpp -lgraph codeaft@codeaft:~$ ./a.out
Enter the x1 coordinate 200
Enter the y1 coordinate 200
Enter the radius of circle 150
Dear User, Thank you for visitng Codeaft. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.