ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

Home » C programs » graphics.h header file functions

Design a car using pre-defined functions of graphics.h in C

In this article, we are going to learn about the pre-defined functions (rectangle() and circle()) of graphics.h header file in C programming language and use them to create a car design.
Submitted by Manu Jemini, on March 20, 2018

Drawing shapes is an important part of graphics in C. To make shapes, we got different function in graphics.h file. These functions are used to make different shapes which in turn make more complex shapes.

To make a car, we will need to make two rectangle and two circles. The position of the circle should be like that, that they will look like the wheels of the car.

The Rectangles should have there one side overlapped with each other and the bottom co-ordinates must be in line. You can decide the size of the rectangle by yourself.

rectangle() function takes four parameters, which will be used as the four co-ordinates of the rectangle. The circle() function takes three parameters which make the location of the center and the radius of the circle.

These functions are from the graphics.h file and it should be included in the program file.

ADVERTISEMENT

graphics.h - Program to design a CAR in C



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

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

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

	//Printing message for user
	outtextxy(100, 100 + 100, "Program to draw a car with pre-defined functions in C graphics");

	//using pre-defined functions like rectangle and circle.

	rectangle(350,275,250,400);
	rectangle(350,350,400,400);
	circle(350,410,10);
	circle(275,410,10);

	getch();
	return 0;
}

Output

graphics.h - design a car program 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.