Area of a circle
The area of a circle is the number of square units within the circle. To calculate the area of a circle the standard formula is: Area = Pi R Square
Area of circle = (A = πr²)
Logic
Here we have taken radius as input from the user, and to calculate the area of the circle we have to multiply the value of pi with the square of the radius.
Value of Pi = (3.14159)
Program
#include <iostream> using namespace std; int main() { float radius, area; cout << "Enter radius of the circle : "; cin >> radius; area = 3.14 * (radius * radius); cout << endl << "Area of circle : " << area; return 0; }
Output
Enter radius of the circle : 25.125
Area of circle : 1982.17
Know more about Pi? – What is Pi?