+ 2

How can I draw a circle by * in c++ ?

5th Oct 2017, 10:53 AM
zahra
zahra - avatar
2 Answers
+ 15
#include<iostream> using namespace std; int main() { float r; cout<< " Enter the Radius"; 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; } } [https://www.quora.com/What-is-the-code-to-draw-a-circle-without-using-graphics-in-c++]
5th Oct 2017, 11:12 AM
Babak
Babak - avatar
0
lotwars
5th Oct 2017, 2:16 PM
Mark Wal
Mark Wal - avatar