Write C++ program to find area of circle

#include <iostream>

using namespace std;


int main()

{

    float radius, area;


    cout << "Enter the radius of the circle: ";

    cin >> radius;


    area = 3.14 * radius * radius;


    cout << "The area of the circle is: " << area << endl;


    return 0;

}

In this program, we first declare two float variables radius and area.

We then ask the user to enter the radius of the circle using cout and cin.

Next, we calculate the area of the circle using the formula area = pi * radius^2, where pi is approximately equal to 3.14.

Finally, we display the area of the circle using cout.

Post a Comment

0 Comments