Here, we have a basic program example to calculate the perimeter and area of a circle using different languages. This program is created in c language, c++, Java, and Python.
Program to calculate perimeter and radius of circle in C language
#include <stdio.h>
int main() {
int radius;
float area, perimeter;
printf("Enter the radius : ");
scanf("%d",radius);
perimeter = 2*3.14*radius;
printf("Perimeter of the Circle = %f inches\n", perimeter);
area = 3.14*radius*radius;
printf("Area of the Circle = %f square inches\n", area);
return(0);
}
Program to calculate perimeter and radius of circle in C++ language
#include<iostream>
#include<stdlib.h>
#include<cmath>
using namespace std;
int main()
{
double r,area,perimeter;
cout<<"Input Radius : ";
cin>>r;
area=M_PI*r*r;
perimeter=2*M_PI*r;
cout<<"Area of Circle : "<< area<<endl;
cout<<"Perimeter of Circle : "<<perimeter;
}
Program to calculate perimeter and radius of circle in Python language
PI = 3.14
R = float(input("Enter radius of the circle: "))
area = (PI*R*R)
perimeter = (2*PI*R)
print("The area of circle is", area)
print("The perimeter of circle is", perimeter)
Program to calculate perimeter and radius of circle in Java language
import java.util.Scanner;
public class circle
{
public static void main(String[] args)
{
int r;
double pi = 3.14, area, parameter;
Scanner s = new Scanner(System.in);
System.out.print("Enter radius of circle: ");
r = s.nextInt();
area = pi * r * r;
System.out.println("Area of circle: "+area);
parameter = pi * r * 2;
System.out.println("Perimeter of circle is: "+parameter);
}
}