Complete C program to draw lines with different colors and co-ordinates
#include<graphics.h>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>
void main()
{
int gm, gd=DETECT;
int x1,x2,y1,y2,c,I;
initgraph(&gd,&gm,””);
while(kbhit()) /* until pressing any key this loop continues */
{
/* to draw rectangle co-ordinates are taken randomly */
x1=rand()%getmaxx();
x2=rand()%getmaxx();
y1=rand()%getmaxy();
y2=rand()%getmaxy();
setcolor(rand ()%16); /*to set the line color */
line(x1,y1,x2,y2); /* to draw the line */
delay(200); /* draw the pixels slowly */
}
getch();
closegraph(); /*closes the graph mode */
}