// To illustrate a circle #include<iostream> using namespace std; int main() { float r; cout<< " Enter the Radius"<<endl; cin>> r; float pr = 2; // pr is the aspected pixel ratio which is almost equal to 2 for (int i = -r; i <= r; i++) // loop for horizontal movement { for (int j = -r; j <= r; j++) // loop for vertical movement { float d = ((i*pr)/r)*((i*pr)/r) + (j/r)*(j/r); //multiplying the i variable with pr to equalize pixel-width with the height if (d >0.95 && d<1.08) // approximation { cout << "*"; } else { cout << " "; } } cout << endl; } return 0; }
Screenshot displaying the output :
There, came a Sigh Of relief, on seeing this output. Our faces finally glowed with those Smiles that this ‘petty’ Circle had blocked :p These were the smiles that had traversed longer paths, may be more than the circumference of this circle :p…The path that started from the vertically elongated circle & ended at the perfect looking circle (via horizontally elongated circle :p )...The path that defines the journey that made A circle look like a circle :p 🙂
I was having troubles with a similar program until I found your solution. Thank you so much for posting.
Glad that it helped. 🙂
The same way can we make parabola and hyperbola too?? I think we need to change the equation only. Thanks
8 1 D:\nnnnnnnnn.cpp [Error] stray ‘\224’ in program