C Program to Find Volume of Cone

In this post, we will learn how to find the volume of a cone using C Programming language.

The amount of space occupied by a cone is referred to as the volume of the cone.

The formula for the volume of the cone is (⅓)πr2h, where h is the height of the cone and r is the radius of the base.

  • Volume of Cone = (⅓) x π x r2 x h

So, without further ado, let’s begin this tutorial.

Contents

C Program to Find Volume of Cone

// C Program to Find Volume of Cone
#include <stdio.h>
int main(){
    float radius, height, volume;
    
    // Asking for input
    printf("Enter the radius of the cone: ");
    scanf("%f", &radius);
    printf("Enter the height of the cone: ");
    scanf("%f", &height);
    
    // Calculating volume of cone
    volume = (22 * radius * radius * height) / (3 * 7);
    
    // Displaying output
    printf("Volume of Cone: %.2f", volume);
    return 0;
}

Output

Enter the radius of the cone: 7
Enter the height of the cone: 14
Volume of Cone: 718.67

How Does This Program Work ?

    float radius, height, volume;

In this program, we have declared three float data type variables named radius, height and volume.

    // Asking for input
    printf("Enter the radius of the cone: ");
    scanf("%f", &radius);
    printf("Enter the height of the cone: ");
    scanf("%f", &height);

Then, the user is asked to enter the radius and height of the cone.

    // Calculating volume of cone
    volume = (22 * radius * radius * height) / (3 * 7);

We calculate the volume using the formula V = (⅓) x π x r2 x h

    // Displaying output
    printf("Volume of Cone: %.2f", volume);

Finally, the result is displayed to the screen using printf() function.

Conclusion

I hope after going through this post, you understand how to find the volume of a cone using C Programming language.

If you have any doubt regarding the program, feel free to contact us in the comment section. We will be delighted to help you.

Also Read:

Leave a Comment

Your email address will not be published.