#include<graphics.h>
#include<stdio.h>
#include<conio.h>
Void main ( )
{
int gdriver=DETECT,gmode,x,y,x1,y1,x2,y2,xend;
float m, b, xinc, yinc, dx, dy;
clrscr( );
initgraph(“&gd,&gm”,“
”);
printf("Enter the
starting point and ending point:-");
scanf("%d%d%d%d",&x1,&x2,&y1,&y2);
dx=x2-x1;
scanf("%d%d%d%d",&x1,&x2,&y1,&y2);
dx=x2-x1;
dy=y2-y1;
m=dx/dy
b=y1-m*x1
if(dx<0)
{
if(dx<0)
{
x=x2;
y=y2;
xend=x1;
y=y2;
xend=x1;
}
else
{
else
{
x=x1;
y=y1;
xend=x2;
y=y1;
xend=x2;
}
loop1:
if(x>xend)
goto
loop:
putpixel(x,y,green):
x++;
y=m*x+b:
goto loop1;
loop:
getch( );
closegraph( );
}