C++ program to draw a line by accepting coordinates from the user
codeaft.cpp
#include<graphics.h>
#include<iostream>usingnamespacestd;intmain(){intgd=0,gm=9,x1,y1,x2,y2;cout<<"Enter the x1 coordinate ";cin>>x1;cout<<"Enter the y1 coordinate ";cin>>y1;cout<<"Enter the x2 coordinate ";cin>>x2;cout<<"Enter the y2 coordinate ";cin>>y2;initgraph(&gd,&gm,NULL);line(x1,y1,x2,y2);delay(2000);return0;}
Output
codeaft@codeaft:~$ g++ codeaft.cpp -lgraph codeaft@codeaft:~$ ./a.out
Enter the x1 coordinate 50
Enter the y1 coordinate 50
Enter the x2 coordinate 150
Enter the y2 coordinate 150
Dear User, Thank you for visitng Codeaft. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.