Home »
C programs »
graphics.h header file functions
sector() function of graphics.h in C
In this article, we are going to learn about the sector() function of graphics.h header file and use it create different shapes with different parameters.
Submitted by Manu Jemini, on March 24, 2018
Making complex shapes and designs in C requires a lot of work. Most of the built in function draw shapes which are common, hence we will need something to make sections of the common shapes.
To make use of this function called sector(), we need to pass six parameters which defines the value of x, y co-ordinates of center, starting angle, end angle, x-radius, y-radius.
All these values are numbers and should be valid. The Example below, shows us how we can create sectors of different shapes and size.
graphics.h - sector() function in C
#include <graphics.h>
#include <conio.h>
int main()
{
//initilizing graphic driver and
//graphic mode variable
int graphicdriver=DETECT,graphicmode;
//calling initgraph
initgraph(&graphicdriver,&graphicmode,"c:\\turboc3\\bgi");
//Printing message for user
outtextxy(20, 20 + 20, "Program to use sector functions to create different shapes in C graphics");
//using sector functions with different parameters
sector(50, 150, 0, 70, 50, 50);
sector(200, 150, 0, 160, 50, 50);
sector(350, 150, 0, 230, 50, 50);
sector(500, 150, 0, 300, 50, 50);
//getch to hold screen
getch();
return 0;
}
Output