Write a program to calculate and print the area and the circumference of a circle using area = πr2 and the circumference =2πr where π = 3.14
Answers
Answered by
6
Answer:
class circle {
public static void main(double r) {
double area = 3.14 * r * r;
double circumference = 2 * 3.14 * r;
System.out.println("Area: " + area + "\nCircumference: " + circumference);
}
}
Answered by
1
Below are the output and the python program for the above question :
Output :
If the user input as 3, then the output is "28.259999999999998" for area and 18.84 for circumference.
If the user input as 4, then the output is "50.24 " for area and 25.12 for circumference.
Explanation:
r=int(input("Enter the radius to find the area and circumference of a circle: "))#Take the input from the user.
print("The area of a circle is: ",3.14*r*r)#Print the area of a circle.
print("the circumference of a circle is: ",2*3.14*r)#Print the circumference of a circle.
Code Explanation :
- The above code is in python language, in which there is an input statement that instructs the user for input and takes the input from the user.
- Then the area and circumference is printed by the help of formula and print function.
Learn more :
- Python : https://brainly.in/question/14689905
Similar questions