C program to find volume of cube,cuboid and cylinder using switch case
Answers
C Program to find the Volume of a Cylinder – In this specific article, we will brief in on how to calculate the volume of a cylinder in C programming. The methods used to do so are as follows:
Using Standard Method
Using Function
Using Pointer
Using Macros
Suitable examples and sample programs have been added to this particular blog post for better understanding. The compiler has also been added to the post where you can execute the codes given.
As you all know, a cylinder is an important three-dimensional figure used in our lives. A cylinder is just an extension of a circle so that it is given a height of some sort.
A cylinder looks like this:
Cylinder
As you can see, this is a cylinder with a radius of 4 inches and a height of 8 inches.
Normally, you can calculate the volume of a cylinder with this formula:
Volume = Pi * r^2 * h.
Thus, the volume of this cylinder is:
Volume = Pi * 4^2 * 8 = 402.12 sq. inch.
Thus, the methods used to calculate the volume of a cylinder in C programming are as follows:
Using Standard Method
1)We need radius and height for calculating the volume of the cylinder.
2)The radius and height values will be stored into the variables “r”, “h”.
3)The calculated volume will store into the variable “vol”.