Write a program to find Area of a circle

22 November 2022

Write a program to find Area of a circle


Description

Get the value for radius from the user and calculate the area of the circle for the given radius.

Area of circle = 3.14*radius*radius

Input

3

Output

28.26


C Program

#include <stdio.h>

int main()

{

    float area,radius;

    printf(“Enter the radius”);

    scanf("%f",&radius);

    area=3.14*radius*radius;

    printf("%0.2f",area);

    return 0;

}


C++ Program

#include <iostream>

using namespace std;

int main()

{

    float area,radius;

    cout<<"Enter the radius: ";

    cin>>radius;

    area=3.14*radius*radius;

    cout<<area;

    return 0;

}


Java

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.print("Enter the radius: ");

float radius = sc.nextFloat();

double area = 3.14 * radius * radius;

System.out.println(area);

}

}


Python

Method 1

radius=float(input("Enter the radius: "))

area=3.14*radius*radius

print(area)

Method 2

from math import pi

radius=float(input("Enter the radius: "))

area=pi*radius*radius

print(area)


Related Articles

Ask Us Anything !