```
#include
#include
#include
#include
#include
void main()
{
int x1,y1,x2,y2,i,len,gdriver=DETECT,gmode,errorcode;
float incx,incy,x,y;
initgraph(&gdriver,&gmode,"c:\\tc\\bgi");
clrscr();
cout << "enter the value of x1,y1,x2,y2"<< endl;
cin >>x1>>y1>>x2>>y2;
len=abs(x2-x1);
if(abs(y2-y1)>len)
len=abs(y2-y1);
incx=(x2-x1)/len;
incy=(y2-y1)/len;
x=x1+0.5;y=y1+0.5;
for(i=1;i<=len;i++) {
putpixel(x,y,9);
x=x+incx;
y=y+incy;
}
getch();
}
```
</div>
Leave a comment