473,397 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

How to display a circle by c++?

i want to disply a circle by c++ on consol
what is the algorithim or code?
Dec 1 '10 #1
2 2746
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
Oralloy
988 Expert 512MB
@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.

Luck!
Oralloy
Dec 1 '10 #3

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

Similar topics

1
by: rdeaton | last post by:
I need to design and code a Java program that calculates and prints the (D) diameter, the (C) circumference, or the (A) area of a circle, given the radius. The program inputs two data items: the...
0
by: Chua Wen Ching | last post by:
Hi.. just wonder i draw a circle in the picturebox1 1) and i want to store the circle in memory (only circle) when i store into bmp... i want to see the circle with transparent...
14
by: Pythor | last post by:
I wrote the following code for a personal project. I need a function that will plot a filled circle in a two dimensional array. I found Bresenham's algorithm, and produced this code. Please tell...
1
by: vikraman | last post by:
Please How can I Disply Text when the curser is at a specific coordinate in the Body/Image,and what is the script?
9
by: saraaana | last post by:
Given the center and a point on the circle, you can use this formula to find the radius of the circle. Write a program that prompts the user to enter the center and a point on the circle. The program...
2
by: Yew12 | last post by:
We are trying to get the following script to display the full date and time. The field we are calling does have both date and time in. Unfortunatly its only returning the date. So I tried putting...
1
by: swethak | last post by:
hi, i have a code to disply the calendar and add events to that. It works fine.But my requirement is to i have to disply a weekly and daily calendar.Any body plz suggest that what modifications i...
2
by: swethak | last post by:
Hi, I want to upload the video files after that disply that all uploaded video files.When click on that video file it will play in media player .(Same as You tube). I am doing all that...
14
by: DeadSilent | last post by:
I have this code and for some reason I keep getting an error where it says "exporting non-public type through public api ".. I'm not sure why this keeps happening but it does so for getCircleInfo /...
3
by: cid11 | last post by:
how could I loop this to repeat the circles with one circle filled with red colour and one without? from graphics import * w = 300 h = 300 win = GraphWin("Red Circle", w, h)
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.