Program to draw an ellipse

#include<iostream.h>

#include<conio.h>

#include<graphics.h>

#include<math.h>

int a(int a)

{

return(getmaxx()/2+a);

}

int b(int b)

{

return(getmaxy()/2-b);

}

void main()

{

int driver=DETECT,gmode;

initgraph(&driver,&gmode,””);

clrscr();

int r1,r,r2,x1,y1,th1,mx,my;

float th=0,y,x,c,s,x2,y2,cl,sl;

mx=getmaxx();

my=getmaxy();

cout<<“\n enter the radius rx and ry:”;

cin>>r1>>r2;

cout<<“\n enter the value of rotation:”;

cin>>r;

line(1,my/2,mx,my/2);

line(mx/2,1,mx/2,my);

while(th<=r1)

{

x=r1*cos(th)-r2*sin(th+r);

y=r2*sin(th)+r1*cos(th+r);

putpixel(a(x),b(y),4);

putpixel(x1,y1,5);

th+=0.01;

}

getch();

closegraph();

}