Professional Documents
Culture Documents
RK2005A03
RK2005A03
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
void main()
{
clrscr();
int gdriver=DETECT,gmode;
float x1,x2,y1,y2,m,x,y;
initgraph (&gdriver,&gmode,D:\\TC\\BGI);
cout<<enter the co-ordinates of first point;
cin>>x1>>y1;
cout<<enter the co-ordinates of second point;
cin>>x2>>y2;
clrscr();
cout<<***************THE RESULTANT LINE IS DRAWN BELOW***********;
x=x1;
y=y1;
m=(y2-y1)/(x2-x1);
while(x<=x2||y<=y2)
{
If(m>1)
{
putpixel(x,y,50);
y=y+1;
x=x+(1/m);
}
else
{
putpixel(x,y,50);
y=y+m;
x=x+1;
}
}
getch();
closegraph();
}