Advertisement
zoro-10

5A. Develop the program for the mid-point circle drawing algorithm

Apr 1st, 2024
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.56 KB | None | 0 0
  1. #include<graphics.h>
  2. #include<iostream.h>
  3. #include<conio.h>
  4. #include<math.h>
  5. void main()
  6. {
  7. int gd=DETECT,gm,x,y,r,p;
  8. initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
  9. cout<<"Enter the radius of the circle:";
  10. cin>>r;
  11. x=0;
  12. y=r;
  13. p=1-r;
  14. do
  15. {
  16. putpixel(100+x,100+y,15);
  17. putpixel(100+x,100-y,15);
  18. putpixel(100+y,100+x,15);
  19. putpixel(100+y,100-x,15);
  20. putpixel(100-x,100+y,15);
  21. putpixel(100-x,100-y,15);
  22. putpixel(100-y,100+x,15);
  23. putpixel(100-y,100-x,15);
  24. if(p<0)
  25. {
  26. x++;
  27. p=p+2*x+3;
  28. }
  29. else
  30. {
  31. x++;
  32. y--;
  33. p=p+2*(x-y)+5;
  34. }
  35. }
  36. while(x<y);
  37. getch();
  38. closegraph();
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement