forked from Rustam-Z/cpp-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSource.cpp
More file actions
29 lines (24 loc) · 852 Bytes
/
Copy pathSource.cpp
File metadata and controls
29 lines (24 loc) · 852 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
// Practical Lab Assignment-7(Week 9)
// ID:U1910049 Name: Rustam Zokirov
// Program to calculate area of a circle using functions
#include <iostream>
#include <math.h> //C++ libriry which is including "pow" and PI=3.14
using namespace std;
float area(float radius)
{ // function for calculating the area
float area;
area = (atan(1) * 4) * (pow(radius, 2)); //"atan" is the function which is finding the PI=3.14
return area;
} // end function "area"
int main1()
{
float radius;
cout << "Please enter the radius of circle: ";
cin >> radius; // inputing the radius
if (radius > 0)
cout << area(radius) << endl; // calling the function "area" for calculating the Area of Circle
else
cout << "INVALID Radius!" << endl; // if radius is a negative number or equal to zero the program will show "Invalid radius"
system("pause");
return 0;
}