//To draw an ellipse using trignometric method
#include<iostream.h>
#include<graphics.h>
#include<conio.h>
#include<math.h>
void put4pixel(int,int,int,int);
void main()
{
int x,y,x1,y1,a,b,h,k,theta;
float p=3.14159/180;
cout<<“\n\t\t\t\*Trignometric method to draw an ellippse*\n”;
cout<<“\nenter the x and y coordinates:-\n”;
cin>>h>>k;
cout<<“\nenter the first radius:-\n”;
cin>>a;
cout<<“\nenter the second radius:-\n”;
cin>>b;
int gd=DETECT,gm;
initgraph(&gd,&gm,””);
setbkcolor(WHITE);
for(theta=0;theta<=90;theta++)
{
x1=a*cos(theta*p);
y1=b*sin(theta*p);
x=int(x1+0.5);
y=int(y1+0.5);
put4pixel(x,y,h,k);
}
setcolor(8);
outtextxy(100,60,”ellipse using Trigonometric method”);
getch();
closegraph();
}
void put4pixel(int x,int y,int h,int k)
{
putpixel(x+h,y+k,8);
putpixel(x+h,-y+k,8);
putpixel(-x+h,y+k,8);
putpixel(-x+h,-y+k,8);
}