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

#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);
}

0 Comments