# Elliptical Arc Algorithm

## Computer graphics program in C++

### C++

Elliptical Arc Algorithm graphics program in C++

```
#include<iostream>
#include<graphics.h>
#include<math.h>
using namespace std;
#define PI 3.141592
void Elli_arc(int xcen,int ycen,int xrad,int yrad,int start_ang,int end_ang)
{
float ang=(((start_ang<=end_ang)?start_ang:end_ang)*(PI/180));
float range=(((end_ang>start_ang)?end_ang:start_ang)*(PI/180));
float x=(xrad*cos(ang));
float y=(yrad*sin(ang));
do
{
putpixel((int)(xcen+x+0.5),(int)(ycen-y+0.5),CYAN);
ang+=0.001;
x=(xrad*cos(ang));
y=(yrad*sin(ang));
}
while(ang<=range);
}
int main(){
int x_cen,y_cen,xrad,yrad,start_ang,end_ang;
cout<<"Enter centre's x_coordinate:";
cin>>x_cen;
cout<<"Enter centre's y_coordinate:";
cin>>y_cen;
cout<<"Enter x_radius of arc:";
cin>>xrad;
cout<<"Enter y_radius of arc:";
cin>>yrad;
cout<<"Enter start angle of arc:";
cin>>start_ang;
cout<<"Enter end angle of arc:";
cin>>end_ang;
int gd=DETECT,gm;
initgraph(&gd,&gm,"");
Elli_arc(x_cen,y_cen,xrad,yrad,start_ang,end_ang);
getch();
closegraph();
return 0;
}
```