Open In App

Java Program for Program to find area of a circle

Improve
Improve
Like Article
Like
Save
Share
Report

Area of a circle can simply be evaluated using following formula.

Area = pi * r2
where r is radius of circle 

Java




// Java program to find area
// of circle
     
class Test
{
    static final double PI = Math.PI;
          
    static double findArea(int r)
    {
       return PI * Math.pow(r, 2);
    }
          
    // Driver method
    public static void main(String[] args)
    {
        System.out.println("Area is " +  findArea(5));
    }
}


Time Complexity: O(log n) since using inbuilt Math.pow function

Auxiliary Space : O(1)

Please refer complete article on Program to find area of a circle for more details!


Last Updated : 24 Jul, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads