#include"stdio.h"
#include"conio.h"
#include"graphics.h"
void main()
{
int i=DETECT,M,color=1;
int x1,y1,x2,y2,dx,dy,xend,m,b,x,y,steps,xinc,yinc,k;
clrscr();
initgraph(&i,&M,"");
printf("Enter the values of x1,y1,x2,y2");
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
dx=x2-x1;
dy=y2-y1;
if(abs(dx)>abs(dy))
steps=abs(dx);
else
steps=abs(dy);
xinc = dx/steps;
yinc = dy/steps;
x=x1;y=y1;
putpixel(x,y,3);
for(k=1;k<=steps;k++)
{
x=x+xinc;
y=y+yinc;
putpixel(x,y,color++);
}getch();
}
Monday, 15 December 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment