ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

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.

ADVERTISEMENT

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

graphics.h - sector() function  in C

ADVERTISEMENT
ADVERTISEMENT




Comments and Discussions

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

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

© https://www.includehelp.com some rights reserved.