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: 23-Mar-2020

4K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements