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
- #include<stdio.h>
- #include<conio.h>
- #define PI 3.1415
- void main()
- {
- float r, h, surf_area, volume;
- clrscr();
- printf(" Enter a size of Height and radius of a cylinder:");
- scanf("%f%f", &h, &r);
- surf_area = 2*PI*r*(r+h);
- volume=PI*r*r*h;
- printf("\n Surface area of cylinder is : %.3f", surf_area);
- print("\n volume of cylinder is:%.3", volume);
- getch();
- }
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