‘C’ program to print the surface area and volume (surface area = 2πr2 + 2πrh, volume = πr2h) of Cylinder
C File =
/* Write a ‘C’ program to accept dimensions of a cylinder and print the
surface area and volume
(surface area = 2πr2 + 2πrh,
volume = πr2h) */
#include<stdio.h>
#define pi 3.142
int main()
{
int r,h;
float sa,v;
printf("\n Enter radius of cylinder : ");
scanf("%d",&r);
printf("\n Enter height of cylinder : ");
scanf("%d",&h);
v=(pi*r*r*h);
sa=(2*pi*r*r)+(2*pi*r*h);
printf("\n Surface Area = %f",sa);
printf("\n Volume = %f",v);
return 0;
}
Comments
Post a Comment
Please do not enter any spam link in message.