#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
void main()
{
int x,y,xi,yi,x1,y1,y2,x2,i,s;
clrscr();
int gd=DETECT,gm;
initgraph(&gd,&gm,"C:\\tc\\")
printf("enter value of x1:");
scanf("%d",&x1);
printf("enter value of y1:");
scanf("%d",&y1);
printf("enter value of x2:");
scanf("%d",&x2);
printf("enter value of y2:");
scanf("%d",&y2);
dx=x2-x1;
dy=y2-y1;
if(abs(dx)>abs(dy))
{
s=abs(dx);
}
else{
s=abs(dy);
}
xi=dx/s;
yi=dy/s;
x=xi;
y=yi;
putpixel(xi,yi,4);
for(i=0;i<s;i++)
{
x+=x1;
y+=y1;
putpixel(x1,y1,4);
}
closegraph();
getch();
}
#include<conio.h>
#include<graphics.h>
#include<math.h>
void main()
{
int x,y,xi,yi,x1,y1,y2,x2,i,s;
clrscr();
int gd=DETECT,gm;
initgraph(&gd,&gm,"C:\\tc\\")
printf("enter value of x1:");
scanf("%d",&x1);
printf("enter value of y1:");
scanf("%d",&y1);
printf("enter value of x2:");
scanf("%d",&x2);
printf("enter value of y2:");
scanf("%d",&y2);
dx=x2-x1;
dy=y2-y1;
if(abs(dx)>abs(dy))
{
s=abs(dx);
}
else{
s=abs(dy);
}
xi=dx/s;
yi=dy/s;
x=xi;
y=yi;
putpixel(xi,yi,4);
for(i=0;i<s;i++)
{
x+=x1;
y+=y1;
putpixel(x1,y1,4);
}
closegraph();
getch();
}