write a C program to accept dimension and display the surface atea and volume of cylinder?
Answers
Answer:
Write a c program to find the volume and surface area of cylinder
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
Answer:
Explanation:
#include<conio.h>
#include<stdio.h>
void main()
{
float r,h,v,A; //declare variables r=radius, h=height , v=volume , A=area
float p=3.14;
//accepting radius(r) and height(h)
printf("\nEnter Value of radius:");
scanf("%f",&r);
printf("\nEnter Value of height:");
scanf("%f",&h);
A=(2*p*r*h)+(2*p*r*r); //formula of surface area of cylinder
v=p*r*r*h; //formula of volume of cylinder
printf("Surface Area of Cylinder :- %f ",A);
printf("Volume of Cylinder :- %f ",v);
}