Write a c program to find the volume and surface area of cylinder
C program for area of a cylinder
C code:
#include<stdio.h>
#include<math.h>
int main(){
float r,h;
float surface_area,volume;
printf("Enter size of radius and height of a cylinder : ");
scanf("%f%f",&r,&h);
surface_area = 2 * M_PI * r * (r + h);
volume = M_PI * r * r * h;
printf("Surface area of cylinder is: %.3f",surface_area);
printf("\nVolume of cylinder is : %.3f",volume);
return 0;
}
Sample output:
Enter size of radius and height of a cylinder: 4 10
Surface area of cylinder is: 351.858
Volume of cylinder is: 502.655
Formula of surface area of cylinder:
Surface_area = 2 * Pie * r * (r + h)
Formula of volume of cylinder:
Volume = Pie * r * r * h
Pie = 22/7 or 3.1415926535....
No comments:
Post a Comment