By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,601 Members | 1,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,601 IT Pros & Developers. It's quick & easy.

How to display a circle by c++?

P: 1
i want to disply a circle by c++ on consol
what is the algorithim or code?
Dec 1 '10 #1
Share this Question
Share on Google+
2 Replies

P: 7
If you want to display circle only using console I am not sure.
But the alternate way is, you can use GLUT libraries or QT in C++ code.
Dec 1 '10 #2

Expert 100+
P: 983
@skoo dana,

When you say console, do you mean a GUI console, or a simple text console?

If you have a GUI, the method depends on the system and tools you have available.

If you are dealing with a character-cell terminal console, then for your first cut I would suggest building an internal two-dimensional array and "plotting" the circle there. Once you've "plotted" the circle in-memory, then all you have to do is loop around the lines and print them out.

To calculate the points, you can walk down each line and invert the [icode]X^2 + Y^2 = R^2[icode] relationship, or you can find the locations explicitly by mapping the points (R*cos(angle), R*sin(angle)) explicitly.

In either case, I think that you'll be amused by the display artifacts generated. There is a whole science to low-level graphics, which most people don't see. The algorithms are actually quite elegant, once you understand them.

It all depends on what you really need to accomplish, and why. If you can give us clearer requirements, perhaps we can give you more information.

Dec 1 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.