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;
}
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;
}
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; }
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us