Learn about C Program to Find Area and Volume of a Cylinder in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.
Contents
C Program to Find Area and Volume of a Cylinder
To calculate the volume of a cylinder, Using the equation πr² where r is the radius of the circle, calculate the area of the base (which is a circle). The volume is then calculated by multiplying the area of the base by the height of the cylinder.
Program:
#include<stdio.h>
int main()
{
double height, radius, area, volume;
printf("Enter radius and height: ");
scanf("%lf %lf",&radius, &height);
area = 3.14 * (radius* radius);
volume = area * height;
printf("Area=%.2f \t Volume=%.2f", area, volume);
return 0;
}
Output:
Enter radius and height: 5 10
Area=78.50
Volume=785.00
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Codes :
C Program to Find Volume of a Rectangular Box
C Program to Find the Volume of a Cube Using pow() Function