In mathematics, an ellipse (from the Greek for absence) is a plane algebraic curve where the sum of the distances from any point on the curve to two fixed points is constant. The two fixed points are called foci (plural of focus).

An ellipse is a type of conic section: if a conical surface is cut with a plane which does not intersect the cone's base, the intersection of the cone and plane is an ellipse.

Algebraically, an ellipse is a curve in the Cartesian plane defined by an equation of the form Ax2 + Bxy + Cy2 + Dx + Ey + F = 0 such that B2 < 4AC, where all of the coefficients are real, and where more than one solution, defining a pair of points (x, y) on the ellipse, exists.

//Program to plot an ellipse by Bresenham's approach

#include <iostream.h>
#include <graphics.h>
#include <math.h>
#include <conio.h>

void drawe(int x1, int y1, long a, long b)
{
	long x=0,y=b;
	float p;
	putpixel(x1+getmaxx()/2, getmaxy()/2-y1,1);
	p=2*b*b+a*a*(1-2*b);
	while (y>0)
	{
	if (b*b*x<a*a*y)
	{
		if (p<=a*a/2)
			p+=2*b*b*(3+2*x);
		else
			p+=2*b*b*(3+2*x)-4*a*a*(y-1), y--;
		x++;
	}
	else
	{
		if (p<=b*b/2)
			p+=2*a*a+4*a*a*(y-1);
		else
			p+=2*a*a+4*a*a*(y-1)-4*b*b*(x+1), x++;
		y--;
	}
	putpixel(x+getmaxx()/2+x1,y+getmaxy()/2-y1,5);
	putpixel(-x+getmaxx()/2+x1 ,y+getmaxy()/2-y1,5);
	putpixel(x+getmaxx()/2+x1,-y+getmaxy()/2-y1,5);
	putpixel(-x+getmaxx()/2+x1,-y+getmaxy()/2-y1,5);
	}
}

void main()
{
	int x1, y1, a, b;
	int gdriver = DETECT, gmode, errorcode;
	initgraph(&gdriver, &gmode, "");
	line(0,getmaxy()/2,getmaxx(),getmaxy()/2);
	line(getmaxx()/2,0,getmaxx()/2,getmaxy());
	cout<<"Enter x1 ";
	cin>>x1;
	cout<<"Enter y1 ";
	cin>>y1;
	cout<<"Enter a ";
	cin>>a;
	cout<<"Enter b ";
	cin>>b;
	drawe(x1,y1,a,b);
	getch();
}