Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<iostream.h>
- #include<conio.h>
- #include<graphics.h>
- #include<math.h>
- void main()
- {
- float x,y,x1,y1,x2,y2,dx,dy,step;
- int i, gd=DETECT, gm;
- initgraph(&gd,&gm,"...\\bgi");
- cout<<"enter value of x1 amd y1";
- cin>>x1>>y1;
- cout<<"enter value of x2 & y2";
- cin>>x2>>y2;
- dx=abs (x2-x1);
- dy=abs(y2-y1);
- if(dx>=dy)
- step=dx;
- else
- step=dy;
- dx=dx/step;
- dy=dy/step;
- x=x1;
- y=y1;
- i=1;
- while(i<=step)
- {
- putpixel(x,y,5);
- x=x+dx;
- y=y+dy;
- i=i+1;
- delay(100);
- }
- getch();
- closegraph();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement