Line() Function

line() function is used to draw the line from one position to another position on the screen.

Declaration

int getmaxcolor();
  • It contains forr arguments, first two arguments represents the X and Y coordinates of the starting point of line and last two arguments represents the X and Y coordinates of the ending point of the line.
  • For better understanding go through the program:

Program

#include<stdio.h>

#include<conio.h>

#include<graphics.h>

void main()

{

int gd=DETECT, gm;

initgraph(&gd,&gm," ");

line (100,200,200,200);

getch();

closegraph();

}

The above program is used to draw the line on the screen. In the above program a line has been drawn with starting point (100,200) and ending point (200,200). It is a horizontal line because only X-coordinate increases and Y- coordinate does not change.

Output

c graphics