C program to find volume and surface area of Cylinder; Through this tutorial, we will learn how to find or calculate volume and surface area of Cylinder using standard formula and function in c programs.
Programs to Find Volume and Surface Area of Cylinder in C
To find or calculate volume and surface area of Cylinder using standard formula and function in c:
- C Program to Find Volume and Surface Area of Cylinder using Standard Formula
- C Program to Find Volume and Surface Area of Cylinder using Function
C Program to Find Volume and Surface Area of Cylinder using Standard Formula
/* C Program to find Volume and Surface Area of a Cylinder */
#include<stdio.h>
#include<math.h>
int main()
{
float radius, height;
// L = Lateral Surface Area of a Cylinder, T = Top Surface Area
float sa,Volume, L, T;
printf("\n Please Enter the radius and height of a cylinder :- ");
scanf("%f %f", &radius, &height);
sa = 2 * M_PI * radius * (radius + height);
Volume = M_PI * radius * radius * height;
L = 2 * M_PI * radius * height;
T = M_PI * radius * radius;
printf("\n Surface Area of a cylinder = %.2f", sa);
printf("\n Volume of a Cylinder = %.2f", Volume);
printf("\n Lateral Surface Area of a cylinder = %.2f", L);
printf("\n Top OR Bottom Surface Area of a cylinder = %.2f", T);
return 0;
}
The output of the above c program; as follows:
Please Enter the radius and height of a cylinder :- 10 15 Surface Area of a cylinder = 1570.80 Volume of a Cylinder = 4712.39 Lateral Surface Area of a cylinder = 942.48 Top OR Bottom Surface Area of a cylinder = 314.16
C Program to Find Volume and Surface Area of Cylinder using Function
#include <stdio.h>
#include<math.h>
float volSur(float radius, float height)
{
// L = Lateral Surface Area of a Cylinder, T = Top Surface Area
float sa,Volume, L, T;
sa = 2 * M_PI * radius * (radius + height);
Volume = M_PI * radius * radius * height;
L = 2 * M_PI * radius * height;
T = M_PI * radius * radius;
printf("\n Surface Area of a cylinder = %.2f", sa);
printf("\n Volume of a Cylinder = %.2f", Volume);
printf("\n Lateral Surface Area of a cylinder = %.2f", L);
printf("\n Top OR Bottom Surface Area of a cylinder = %.2f", T);
}
int main()
{
float radius, height;
printf("\n Please Enter the radius and height of a cylinder :- ");
scanf("%f %f", &radius, &height);
volSur(radius, height);
return 0;
}
The output of the above c program; as follows:
Please Enter the radius and height of a cylinder :- 10 15 Surface Area of a cylinder = 1570.80 Volume of a Cylinder = 4712.39 Lateral Surface Area of a cylinder = 942.48 Top OR Bottom Surface Area of a cylinder = 314.16