VOOZH about

URL: https://www.geeksforgeeks.org/dsa/draw-circle-without-floating-point-arithmetic-unpublished/

⇱ Draw a circle without floating point arithmetic - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Draw a circle without floating point arithmetic

Last Updated : 16 Dec, 2022

Given a radius of a circle, draw the circle without using floating point arithmetic.
The following program uses a simple concept. Let the radius of the circle be r. Consider a square of size (2r+1)*(2r+1) around the circle to be drawn. Now walk through every point inside the square. For every point (x,y), if (x, y) lies inside the circle (or x^2+ y^2 < r^2), then print it, otherwise print space.


Output
 . . . 
 . . . . . . . . . 
 . . . . . . . . . . . 
 . . . . . . . . . . . . . 
 . . . . . . . . . . . . . . . 
 . . . . . . . . . . . . . . . 
 . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . . 
 . . . . . . . . . . . . . . . 
 . . . . . . . . . . . . . . . 
 . . . . . . . . . . . . . . . 
 . . . . . . . . . . . . . 
 . . . . . . . . . . . 
 . . . . . . . . . 
 . . . 

Time complexity: O(N2)
Auxiliary space: O(1)

Comment
Article Tags: