SHARE
TWEET

biraj lauda

a guest Dec 15th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. #include<iostream.h>
  3. #include<conio.h>
  4. #include<graphics.h>
  5. #include<math.h>
  6.  
  7. void main()
  8. {
  9. float x,y,x1,y1,x2,y2,dx,dy,step;
  10. int i, gd=DETECT, gm;
  11. initgraph(&gd,&gm,"...\\bgi");
  12. cout<<"enter value of x1 amd y1";
  13. cin>>x1>>y1;
  14. cout<<"enter value of x2 & y2";
  15. cin>>x2>>y2;
  16. dx=abs (x2-x1);
  17. dy=abs(y2-y1);
  18. if(dx>=dy)
  19. step=dx;
  20. else
  21. step=dy;
  22. dx=dx/step;
  23. dy=dy/step;
  24. x=x1;
  25.  
  26. y=y1;
  27. i=1;
  28. while(i<=step)
  29. {
  30. putpixel(x,y,5);
  31. x=x+dx;
  32. y=y+dy;
  33. i=i+1;
  34. delay(100);
  35. }
  36. getch();
  37. closegraph();
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top