#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int x1,y1,xn,yn,X,Y,dx,dy,xinc,yinc,i,length;
int gd=DETECT ,gm;
initgraph(&gd,&gm,"C:\\TC\\BGI");
printf("Enter the initial points:");
scanf("%d%d",&x1,&y1);
printf("Enter the end points:");
scanf("%d%d",&xn,&yn);
dx=xn-x1;
dy=yn-y1;
if(dx<=dy)
{
length=dy;
}
else
{
length=dx;
}
xinc=dx/length;
yinc=dy/length;
X=x1;
Y=y1;
i=1;
putpixel(X,Y,RED);
while(i<=length)
{
X=X+xinc;
Y=Y+yinc;
i++;
putpixel(X,Y,RED);
}
getch();
closegraph();
}
#include<conio.h>
#include<graphics.h>
void main()
{
int x1,y1,xn,yn,X,Y,dx,dy,xinc,yinc,i,length;
int gd=DETECT ,gm;
initgraph(&gd,&gm,"C:\\TC\\BGI");
printf("Enter the initial points:");
scanf("%d%d",&x1,&y1);
printf("Enter the end points:");
scanf("%d%d",&xn,&yn);
dx=xn-x1;
dy=yn-y1;
if(dx<=dy)
{
length=dy;
}
else
{
length=dx;
}
xinc=dx/length;
yinc=dy/length;
X=x1;
Y=y1;
i=1;
putpixel(X,Y,RED);
while(i<=length)
{
X=X+xinc;
Y=Y+yinc;
i++;
putpixel(X,Y,RED);
}
getch();
closegraph();
}
No comments:
Post a Comment