Program to find area of a circle

1

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

Area-of-circle

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

Python3

# Python program to find Area of a circle

def findArea(r):
    PI = 3.142
    return PI * (r*r);

# Driver method
print("Area is %.6f" % findArea(5));

# This code is contributed by Chinmoy Lenka


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)