program to find area of a circle

1

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

Area = pi * r2
where r is radius of circle 

C

#include <stdio.h>
#include <math.h>
#define PI 3.142

double findArea(int r)
{
   return PI * pow(r, 2);
}

int main()
{
    printf("Area is %f", findArea(5));
    return 0;
}

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));
	}
}


Output:
Area is 78.550000

GATE CS Corner    Company Wise Coding Practice

Recommended Posts:



1 Average Difficulty : 1/5.0
Based on 1 vote(s)










Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.