Program to calculate area of a circle

Description

To calculate area follow the formula of pi*radius*radius.
Here assume pi=3.14.

C/C++

/* C Prgram to calculate area of circle */
//Save it as AreaCircle.c

#include<stdio.h>
int main(){

    float radius, area;

    printf("Enter the radius of circle : ");
    scanf("%f",&radius);

    area = 3.14 * radius * radius;

    printf("The area of circle : %.2f", area);

    return 0;
}
Input:
Enter the radius of circle : 7

Output:
The area of circle : 153.86

Java

/* Java Prgram to calculate area of circle */
//Save it as AreaCircle.java


import java.io.*;
import java.util.Scanner;

public class AreaCircle {

    public static void main(String[] args) {
        
        Scanner scanner = new Scanner(System.in);
        
        float radius, area;
        
        System.out.println("Enter the radius of circle : ");
        radius = scanner.nextFloat();
        
        area = (float) (3.14 * radius * radius);
        
        System.out.println("The area of circle : "+ area);
        
    }
}
Input:
Enter the radius of circle : 
7

Output:
The area of circle : 153.86

Related Programs

1) Program to calculate area of triangle
2) Program to calculate Area of right angle triangle
3) Program to calculate area of square
4) Program to calculate area of a Rectangle
5) Program to calculate volume and surface area of cube
6) Program to calculate volume and surface area of cylinder
7) Program to calculate Volume and Surface Area of Sphere
Share Me

Leave a Reply