Home » C programs » graphics.h header file functions

circle() and ellipse() functions of graphics.h in C

In this article, we are going to learn about the circle() and ellipse() functions of graphics.h header file in C programming language and then create a circle and ellipse using these functions.
Submitted by Manu Jemini, on March 18, 2018

Making a circle and an ellipse in C can be done easily. How to do is, first initialize a graph with two parameters and a path to the "bgi" folder in your system.

After that, we will call the function called circle() with three numbers as the coordinates of the center and radius. So this function will create a circle with a center with the given radius.

To make an ellipse on the screen, all we need to do is call the ellipse() function with six numbers as the coordinates of the ellipse. These six co-ordinates decide the location of the ellipse, angles, and radius from X-axis and Y-axis.

To use these function in your program, we would need to include graphics.h file in your program. You should also use getch() function to make the screen freeze.

graphics.h - circle() and ellipse() functions Example in C

#include <graphics.h>
#include <conio.h>
#include <dos.h>
#include <stdlib.h>

void main() {
	//initilizing graphic driver and 
	//graphic mode variable
	int graphicdriver=DETECT,graphicmode;

	//calling initgraph function with 
	//certain parameters

	//Printing message for user
	outtextxy(10, 10 + 10, "Program to draw circle and ellipse in C graphics");

	//calling circle function
	circle(100, 100, 50);

	//calling ellipse function



graphics.h - circle() and ellipse() functions example in C


Comments and Discussions




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.