Monday, 29 February 2016

Area of a circle using C++

The area of a circle is the number of square units inside that circle. If each square in the circle to the left has an area of 1 cm2, you could count the total number of squares to get the area of this circle. Thus, if there were a total of 28.26 squares, the area of this circle would be 28.26 cm2 However, it is easier to use one of the following formulas:
Area equals Pi times r squared space or space Area equals Pi times r times r
where Area is the area, and radius is the radius. Let's look at some examples involving the area of a circle. In each of the three examples below, we will use Pi= 3.14 in our calculations.

Source code:

#include <iostream>
using namespace std;
int main()
{
    float radius,A;
    cout<<"Enter the Radius : ";
    cin>>radius;
    A=3.14*r*r;
    cout<<"Area of Circle : "<<A;

    return 0;
}

No comments:

Post a Comment