Introduction :
In this article I will show you how to draw line from one point to another point by C or C++ using line function. line is built-in function in graphics header
Declaration :
line(int x1,int y1, int x2,int y2);
How to use :
For use this function you have to install turboc++. In this example I will show you how to draw a line using C or C++ programing. The following code draws a line. Just create a c or c++ file in turboc++ and copy paste following code in it.
/*Developed by Puskar Jasu*/
#include <graphics.h>
#include <conio.h>
main()
{
int x1, x2, y1, y2;
int graphic_driver = DETECT, graphic_mode;
initgraph(&graphic_driver, &graphic_mode, "//turboc3/bgi");
setcolor(4);
x1 = 100;
x2 = 400;
y1 = 100;
y2 = 300;
line(x1, y1, x2, y2);
getch();
closegraph();
return 0;
}
Output :
You can see the output of above code.
Conclusion :
In this article I show you how you draw line in C graphics by turboc++. Thanks for visit my site.
You can see my following project :
- draw arc with color by c with source code
- How to create banner by c with source code
- how to create lighting with sound by c graphics with source code