#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include<dos.h>
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
int stangle = 0, endangle = 360;
int xradius = 100, yradius = 50;
/* initialize graphics, local variables */
initgraph(&gdriver, &gmode, “”);
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk)
/* an error occurred */
{
printf(“Graphics error: %s\n”, grapherrormsg(errorcode));
printf(“Press any key to halt:”);
getch();
exit(1);
/* terminate with an error code */
}
/* draw ellipse */
ellipse(100,100, stangle, endangle,70,90 );
//putpixel(100,0,3);
//cleardevice();
//putpixel(170,0,3);
circle(180,0,10);
circle(100,190,10);
circle(100,0,10);
float x1,y1,x,y,a,b,fx,fy;
x1=100;
y1=100;
a=80;
b=100;
float d;
x=10;
y=b;
d = a*a*(0.25-b) + b*b;
while((b*b*(x+1))<=(a*a*(y-0.5)))
{
if(d<0)
{
d+= 1.0*b*b*(3+2*x);
x++;
}
else
{
d+= b*b*(3+2*x)*1.0+2*1.0*a*a*(1-y);
x++;
y–;
}
ellipse(100,100, stangle, endangle,70,90 );
circle(x+100,y+100,10);
delay(200);
cleardevice();
}
d = b*b*(1.0*x+0.5)*(1.0*x+0.5)+1.0*a*a*(y-1)*(y-1)-1.0*a*a*b*b;
while(y>=0)
{
if(d<0)
{
d+= 2.0*b*b*(1+x)+1.0*a*a*(3-2*y);
x++;
y–;
}
else
{
d+= a*a*(3-2*y)*1.0;
y–;
}
ellipse(100,100, stangle, endangle,70,90 );
circle(x+100,y+100,10);
delay(200);
cleardevice();
}
x=10;
y=b;
d = a*a*(0.25-b) + b*b;
while((b*b*(x+1))<=(a*a*(y-0.5)))
{
if(d<0)
{
d+= 1.0*b*b*(3+2*x);
x++;
}
else
{
d+= b*b*(3+2*x)*1.0+2*1.0*a*a*(1-y);
x++;
y–;
}
ellipse(100,100, stangle, endangle,70,90 );
circle(100-x,100-y,10);
delay(200);
cleardevice();
}
d = b*b*(1.0*x+0.5)*(1.0*x+0.5)+1.0*a*a*(y-1)*(y-1)-1.0*a*a*b*b;
while(y>=0)
{
if(d<0)
{
d+= 2.0*b*b*(1+x)+1.0*a*a*(3-2*y);
x++;
y–;
}
else
{
d+= a*a*(3-2*y)*1.0;
y–;
}
ellipse(100,100, stangle, endangle,70,90 );
circle(100-x,100-y,10);
delay(200);
cleardevice();
}
cleardevice();
ellipse(100,100,stangle,endangle,80,100);
/* delay(1000);
for(int i=0;i<100;i=i+10)
{ ellipse(100,100, stangle, endangle,70,90 );
circle(100+i,0+i,10);
delay(200);
cleardevice();
}
/* clean up */
getch();
closegraph();
return 0;
}