Draw a circle on console in some different languages.
Let's draw a circle on console or terminal using C++, Python, Javascript, PHP.
Posted on Thu, Aug 25 2022
Hi There,
Welcome to another blog post. Math is great at all. We used various kinds of math in our schools and colleges. In most cases programming is depended on math.
Anyway , lets jump into the topic. Lets try to draw a circle on console using some programming languages. We will mathematical circle equation and it's (x - a)2 + (y - b)2 = r2
But I am going to use it like dx2 + dy2 = r2
I used same condition ( if dx2 + dy2 less or equal than r2 ) according to the equation.
So These are codes bellow :
C++
Python
Javascript
PHP
You can draw a circle using above code. Output should be circle drawn with # on terminal like below :
C++
Python
Javascript (I used nodejs to run the code in terminal as you can see...)
PHP (I run the code in terminal using php cli)
Conclusion
These all programs are done only one work. This instance about the work of all programming languages are same but different syntax. : )
Write about the post
Comments from people (0)