‘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

Popular posts from this blog

Write a program to allocate memory dynamically for n integers. Accept the elements and calculate their sum and average

C program to accept names of n cities and search for city named “Pune”.