Problem statement:- Program to Find the area and perimeter of a circle.
Data requirement:-
Input Data:-radius
Output Data:-area, perimeter
Output Data:-area, perimeter
Program in C
Here is the source code of the C Program to Program to Find the area and perimeter of a circle.
Code:
#include<stdio.h>
int main(){
double radius;
double area,perimeter;
printf("Enter the radius of the circle:");
scanf("%lf",&radius);
area=3.14*radius*radius;
perimeter=2*3.14*radius;
printf("Area of the Circle = %0.2lf",area);
printf("\nPerimeter of the Circle = %0.2lf",perimeter);
return 0;
}
Input/Output:
Enter the radius of the circle:5
Area of the Circle = 78.50
Perimeter of the Circle = 31.40
Perimeter of the Circle = 31.40
Program in C++
Here is the source code of the C++ Program to Program to Find the area and perimeter of a circle.
Code:
#include <iostream>
using namespace std;int main()
{
double radius;
double area,perimeter;
cout<<"Enter the radius of the circle:";
cin>>radius;
area=3.14*radius*radius;
perimeter=2*3.14*radius;
cout<<"Area of the Circle = "<<area;
cout<<"\nPerimeter of the Circle = "<<perimeter;
return 0;
}
Input/Output:
Enter the radius of the circle: 9
Area of the Circle = 254.34
Perimeter of the Circle = 56.52
Perimeter of the Circle = 56.52
Program in Java
Here is the source code of the Java Program to Program to Find the area and perimeter of a circle.
Code:
import java.util.Scanner;
public class AreaPerimeterCircle {public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
double radius;
double area, perimeter;
System.out.println("Enter the radius of the circle:");
radius=cs.nextDouble();
area=3.14*radius*radius;
perimeter=2*3.14*radius;
System.out.println("Area of the Circle = "+area);
System.out.println("\nPerimeter of the Circle = "+perimeter);
cs.close();
}
}
Input/Output:
Enter the radius of the circle:
11
Area of the Circle = 379.94
Perimeter of the Circle = 69.08
Area of the Circle = 379.94
Perimeter of the Circle = 69.08
Program in Python
Here is the source code of the Python Program to Program to Find the area and perimeter of a circle.
Code:
radius=int(input("Enter the radius of a circle :"))
area=3.14*radius*radius
perimeter=2*3.14*radius
print("Area =",area)
print("Perimeter =",perimeter)
area=3.14*radius*radius
perimeter=2*3.14*radius
print("Area =",area)
print("Perimeter =",perimeter)
Input/Output:
Enter the radius of a circle: 4
Area = 50.24
Perimeter = 25.12
Area = 50.24
Perimeter = 25.12
Most Recommend Questions:-
More Questions:-
0 Comments
Please do not Enter any spam link in the comment box