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:

  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. int main() {
  5. float pie, r, area;
  6. pie = 3.14;
  7. cout << "Enter the value of radius: " << endl;
  8. cin >> r;
  9. area = 3.14 * pow(r,2);
  10. cout << "Area of circle: " << area;
  11. return 0;
  12. }

Output:

Enter the value of radius: 3
Area of circle: 28.26