wap to find out area of the circle and ask the user to
enter its radius and
assign a variable of pi
Answers
Answer:
int circle_radius;
float PI_VALUE=3.14, circle_area, circle_circumf;
//Ask user to enter the radius of circle
printf("\nEnter radius of circle: ");
//Storing the user input into variable circle_radius
scanf("%d",&circle_radius);
//Calculate and display Area
circle_area = PI_VALUE * circle_radius * circle_radius;
printf("\nArea of circle is: %f",circle_area);
//Caluclate and display Circumference
circle_circumf = 2 * PI_VALUE * circle_radius;
printf("\nCircumference of circle is: %f",circle_circumf);
return(0);
}
Output:
Enter radius of circle: 2
Area of circle is: 12.560000
Circumference of circle is: 12.560000
If you want more accurate results then take PI value as 22/7 instead of 3.14, it would give you the exact values of area and circumference.
Enjoyed this post? Try these related posts
C Program to find Palindrome numbers in a given range
C Program to concatenate two strings without using strcat
C Program to convert uppercase string to lowercase string
C Program for bubble sorting
C program to Reverse a String using recursion
C Program to Convert Binary Number to Decimal Number
Comments
Tumelo says
MARCH 22, 2016 AT 5:30 PM
can you guys help me out here.
write a console program that calculate the area a and circuference c of the circle
a= p x r2
c=2 x p x r
you can send it on my email please.
Explanation:
Answer:
java
import java.util.*;
Explanation:
Scanner s = new Scanner(System.in);
float pi = 22/7f;
System.out.println("enter radius");
float r = s.nextInt();
System.out.println("area of circle" + " " + pi * r * r);