You are on page 1of 1

visit-www.Codes2u.

com
#include<stdio.h> #include<conio.h> #include<graphics.h> #include<math.h> void main() { clrscr(); int xa,xb,ya,yb,y,x,k; float dx,dy,step,xinc,yinc; printf("enter all four points\n"); scanf("%d %d %d %d",&xa,&xb,&ya,&yb); int gd,gm; gd=DETECT; initgraph(&gd,&gm,"c:\\tc\\bgi" ); x=xa; y=ya; dx=xb-xa; dy=yb-ya; if(abs(dx)>abs(dy)) step=abs(dx); else step=abs(dy); xinc=dx/step; yinc=dy/step; for(k=0;k<step;k++) { x+=xinc; y+=yinc; putpixel(x,y,RED); } getch(); }

You might also like