A Program to Find the Area of a Circle
In this example, we are giving a program to find the area of a circle. The rule of finding an area is: A = πr2.
Program to find the area of a circle:
#include <iostream>#include <cmath>using namespace std;int main() {float pie, r, area;pie = 3.14;cout << "Enter the value of radius: " << endl;cin >> r;area = 3.14 * pow(r,2);cout << "Area of circle: " << area;return 0;}
Output:
Enter the value of radius: 3 Area of circle: 28.26