Write a program to calculate area and perimeter of circle after obtaining
radius r from use
Answers
Answer:
#include <stdio.h>
int main() {
int radius;
float area, perimeter;
radius = 6;
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);
}
Following is the program in JAVA language to calculate the area and perimeter of the circle with radius 'r'.
import java.util.Scanner;
public class circle {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the radius of the circle: ");
int r = sc.nextInt();
// Let, 'P' be the perimeter of the circle.
float p = (float) (2*3.14*r);
// Let, 'A' be the area of the circle.
float A = (float) (3.14*r*r);
System.out.println("The Perimeter of the Circle is:" + p+ " units.");
System.out.println("The Area of the circle is:" + A + " square units.");
}
}
#SPJ3