Hi to all.
I want to make a figure "Circle" with stars.
I think i can make this with the help of for loop but not getting its logic. So plz tell me how can i make circle ?
thanks
There are several options, but the simplest might be to make yourself a 2D char array of the proper size (for example, an array of strings).
So, if the user wants a 10 by 10 circle of stars (asterisks), make a 10 by 10 array of characters. Then using a little trigonometry (#include <cmath>) or something like bresenham's circle algorithm you can fill the array. Once done, just cout the array to the display.
It is entirely possible to do it without the array. In this variation, you'll just want to do a simple line-intersection scan, top to bottom, down the circle for each line of text, remembering to cap the top and bottom.
A related consideration is that a text character cell is rarely square. You may want to scale the circle a little to adjust for aspect ratio.
To test if a given point lies on the circle, just use the Pythagorean theorem. Use a right triangle formed between the center of the circle and extending to the point being tested. Determine the length of the hypotenuse and if it is equal to the radius, the point is on the circle.
My dear.
i dont know about Arrays yet b/c i m just learning C++.
So at this time i know only Looping as like for loop and someothers.
So plz tell me its coding in For loop .
So thanks
Try nested for loops, one for each axis on the screen. Then test each "point" with the method posted above. Note that it will look like an oval because of the aspect ratio that Duoas mentioned.