Answers for "Program to draw circle in C++"

CSS
0

Area of a Circle in C++ Programming

#include <iostream>
#include <iomanip>
using namespace std;

int main(){
    double R,A;
    cin >> R;
    A = 3.14159 * R * R;
    cout << "A=" << fixed << setprecision(4) << A << endl;
    return 0;
}
Posted by: Guest on June-28-2021
0

Program to draw circle in C++

#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; }  
Posted by: Guest on July-03-2021

Browse Popular Code Answers by Language