arc() function of graphics.h in C

In this article, we are going to learn about the arc() function of graphics.h header file and use it to create a arcs design of different shapes.
Submitted by Manu Jemini, on March 21, 2018

Arcs are very common in graphics as they are the building block of complex shapes. Making arcs is quite simple, as we only need to call a function.

The function to make an arc(), accepts five parameters for x, y co-ordinate, starting angle, end angle and radius. This will make the arc will all the values are fine. The Example below takes care of all these things as it have four arcs implemented.

You should always use getch() function to freeze the screen so that you can see the output. The arc() function is from graphics.h file, which should be included in the program file.

graphics.h - arc() function example in C

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


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

	//calling initgraph with parameters
	initgraph(&graphicdriver,&graphicmode,"c:\\turboc3\\bgi");

	//Printing message for user
	outtextxy(10, 10 + 10, "Program to draw arcs of diffrent sizes in C graphics");

	// creating arcs using arc function.

	arc(100, 100, 0, 100, 50);

	arc(250, 100, 0, 150, 50);

	arc(400, 100, 0, 200, 50);

	arc(550, 100, 0, 250, 50);


	getch();
	return 0;
}

Output

graphics.h - arc() function program in C



Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.