Write a c program to find the volume and surface area of cone

Write a c program to find the volume and surface area of cone


Write a c program or code to find or calculate the volume and surface area of cone

#include<stdio.h>
#include<math.h>

int main(){

    float r,h;
    float surface_area,volume;

    printf("Enter size of radius and height of a cone : ");
    scanf("%f%f",&r,&h);

    surface_area = M_PI * r * (r + sqrt(r*r + h*h));
    volume = (1.0/3) * M_PI * r * r * h;

    printf("Surface area of cone is: %.3f",surface_area);
    printf("\nVolume of cone is : %.3f",volume);

    return 0;
}

Sample output:

Enter size of radius and height of a cone: 3 10
Surface area of cone is: 126.672
Volume of cone is: 94.248
 
Formula of surface area of cone:
Surface_area = Pie * r * (r + √ (r2 + h2))

Formula of volume of cone:
Volume = 1/3 * Pie * r2 * h
Pie = 22/7 or 3.14159265358979323846264338327950288419716939937510...
 

No comments:

Post a Comment