forked from Shubhamlmp/Programming-Practice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5_AreaOfACircle.cpp
More file actions
46 lines (34 loc) · 810 Bytes
/
5_AreaOfACircle.cpp
File metadata and controls
46 lines (34 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
Given a number R calculate the area of a circle using the following formula:
Area = π * R2.
Note: consider π = 3.141592653.
Input
Only one line containing the number R (1 ≤ R ≤ 100).
Output
Print the calculated area, with 9 digits after the decimal point.
*/
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653
int val()
{
double area, R;
//Take radius as input from the user
cin >> R;
//Calculate the area of the circle and store the result in "area"
area = (PI * R) * R;
//Set the precision to 9 as required in the question
cout << fixed << setprecision(9);
//Display the area
cout << area << endl;
return 0;
}
int main()
{
int t = 1;
while (t--)
{
val();
}
return 0;
}