write a c program to find the volume and surface area of cylinder | CTechnotips


C program for area of a cylinder


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.14159265358979323846264338327950288419716939937510...

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

0 comments:

Post a Comment