After reading many previous answers on the same topic, I was finally able to run a graphic code on my machine. If I give constant values to axis and radius, circle is drawn but not a complete circle.
Please let me know what is wrong with this code. Code is written in dev 5.11 with 32 bit GCC.
#include <iostream>
#include <conio.h>
#include <graphics.h>
using namespace std;
main()
{
int x_axis, y_axis, x, radius, r, d;
// request auto detection
int graphdriver = DETECT, graphmode, errorcode;
//initialize graphics mode
initgraph(&graphdriver, &graphmode, "");
cout << "Enter circle x axis: ";
cin >> x_axis;
cout << "Enter circle y axis: ";
cin >> y_axis;
cout << "Enter circle radius: ";
cin >> radius;
r=radius;
d=1-r;
while (x<radius)
{
if (d<0)
{
d=d+2*x+3;
}
else
{
d=d+2*(x-radius)+5;
delay(200);
radius=radius-1;
}
x=x+1;
putpixel(x+x_axis,radius+y_axis,1);
putpixel(radius+x_axis,x+y_axis,2);
putpixel(-radius+x_axis,x+y_axis,3);
putpixel(-x+x_axis,radius+y_axis,4);
putpixel(-x+x_axis,-radius+y_axis,5);
putpixel(-radius+x_axis,-x+y_axis,6);
putpixel(radius+x_axis,-x+y_axis,7);
putpixel(x+x_axis,-radius+y_axis,8);
}
getch();
}