To run the program we have to include the below header file:
Approach: The idea is to create a triangle with the help of several lines. We will draw a line in graphics by passing 4 numbers to line() function as:
line(a, b, c, d)
The above function will draw a line from coordinates (a, b) to (c, d) in the output window.
Below is the implementation of the above approach:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Draw ellipse in C graphics
- Draw a line in C++ graphics
- Draw Rectangle in C graphics
- Draw circle in C graphics
- Draw a moving car using computer graphics programming in C
- Draw an Ellipse rotating over a Circle in C++ graphics
- Draw a smiley face using Graphics in C language
- Draw an ellipse divided by straight line into two colored part in C++ Graphics
- Sierpinski Triangle using Graphics
- DDA Line generation Algorithm in Computer Graphics
- Creating a Rainbow using Graphics Programming in C
- Point Clipping Algorithm in Computer Graphics
- How to add "graphics.h" C/C++ library to gcc compiler in Linux
- 2D Transformation in Computer Graphics | Set 1 (Scaling of Objects)
- Translation of objects in computer graphics
- Vector vs Raster Graphics
- How to include graphics.h in CodeBlocks?
- bar() function in C graphics
- bar3d() function in C graphics
- Segments in Computer Graphics
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.