Advertisement
Guest User

dda.c

a guest
Oct 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. #include<graphics.h>
  2. #include<stdio.h>
  3. #include<math.h>
  4. #include<dos.h>
  5. #include<conio.h>
  6. void main()
  7. {
  8. float x,y,x1,y1,x2,y2,dx,dy,step;
  9. int i,gd=DETECT,gm;
  10. clrscr();
  11. detectgraph(&gd,&gm);
  12. initgraph(&gd,&gm,"c:\\Turboc++\\Disk\\Turboc3\\BGI");
  13. printf("Enter the value of x1 and y1 \n");
  14. scanf("%f%f",&x1,&y1);
  15. printf("Enter the value of x2 and y2 \n");
  16. scanf("%f%f",&x2,&y2);
  17. dx=abs(x2-x1);
  18. dy=abs(y2-y1);
  19. if(dx>=dy)
  20. step=dx;
  21. else
  22. step=dy;
  23. dx=dx/step;
  24. dy=dy/step;
  25. x=x1;
  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. closegraph();
  37. getch();
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement