Friday, February 10, 2023

Program to accept the dimension and display surface area and volume of a cylinder

Write a program to accept the dimensions of a cylinder and display the surface area and volume of a cylinder:

Formula of the surface area of cylinder:-
surface_area=2*pie*r(r+h)

Formula of volume of cylinder:-
volume=pie*r*r*h

pie = 22/7

  1. #include<stdio.h> 
  2. #include<conio.h>
  3. #define PI 3.1415
  4. void main()
  5.   {   
  6.     float r,  h, surf_area, volume;  
  7.     clrscr();
  8.     printf(" Enter a size of Height and radius of a cylinder:");
  9.     scanf("%f%f", &h, &r);
  10.     surf_area = 2*PI*r*(r+h);  
  11.     volume=PI*r*r*h;
  12.     printf("\n Surface area of cylinder is : %.3f", surf_area);  
  13.     print("\n volume of cylinder is:%.3", volume);
  14.     getch();
  15.    }  

 output:- 
            Enter a size of height and radius of a cylinder: 4 2
            Surface area of cylinder is : 75.407997
            Volume of cylinder is: 50.271999