Draw a Line in C++ Graphics



In this tutorial, we will be discussing a program to draw a line in C++ graphics.

To implement different shapes and sizes, animations, graphics.h library is used in C++.

Example

#include <graphics.h>
int main(){
   int gd = DETECT, gm;
   initgraph(&gd, &gm, "");
   line(150, 150, 450, 150);
   line(150, 200, 450, 200);
   line(150, 250, 450, 250);
   getch();
   closegraph();
   return 0;
}

Output

Updated on: 2020-03-23T08:30:09+05:30

6K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements