In: Computer Science
Write a 'C' program to calculate the surface area of the cone and by using that, also calculate the volume of the cone and print the values as surface area of the cone and volume of the cone.
where as:
surface area of the cone = πr2 (r is the radius of the surface)
volume of the cone = (1/3)πr2h (h is the height of the cone)
Source Code
#include <stdio.h>
#include <math.h>
int main()
{
float radius, height;
float surface_area, volume;
printf("Enter value of radius and height of a cone :");
scanf("%f%f", &radius, &height);
surface_area = (22 / 7) * radius * radius;
volume = (1.0/3) * surface_area * height;
printf("Surface area of cone is: %.3f", surface_area);
printf("\nVolume of cone is : %.3f", volume);
return 0;
}
Screenshot
please give a upvote if u feel helpful.