C Program to Calculate Volume of Ellipsoid

In this post, we will learn how to calculate the volume of an ellipsoid using C Programming language.

The volume of the ellipsoid is the capacity of the ellipsoid or the measure of the amount of space it occupies. The formula to calculate the volume of the ellipsoid is given by: 

  • Volume of Ellipsoid = (4/3) * π * r1 * r2 * r3

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

C Program to Calculate Volume of Ellipsoid

// C Program to Calculate Volume of Ellipsoid
#include <stdio.h>
int main(){
    int r1, r2, r3;
    float volume;
    
    // Asking for input
    printf("Enter the Radius 1: ");
    scanf("%d", &r1);
    printf("Enter the Radius 2: ");
    scanf("%d", &r2);
    printf("Enter the Radius 3: ");
    scanf("%d", &r3);
    
    // Calculating volume
    volume = (4/3.0) * 3.14 * r1 * r2 * r3;
    
    // Displaying output
    printf("Volume of Ellipsoid: %.2f", volume);
    return 0;
}

Output

Enter the Radius 1: 2
Enter the Radius 2: 3
Enter the Radius 3: 4
Volume of Ellipsoid: 100.48

How Does This Program Work ?

    int r1, r2, r3;
    float volume;

In this program, we have declared three int data type variables and one float data type variable.

    // Asking for input
    printf("Enter the Radius 1: ");
    scanf("%d", &r1);
    printf("Enter the Radius 2: ");
    scanf("%d", &r2);
    printf("Enter the Radius 3: ");
    scanf("%d", &r3);

Then, the user is asked to enter the value of all the radii of the ellipsoid.

    // Calculating volume
    volume = (4/3.0) * 3.14 * r1 * r2 * r3;

We calculate the volume using the formula, V = (4/3) * π * r1 * r2 * r3.

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

Finally, the volume of the ellipsoid is printed on the screen using printf() function.

Conclusion

I hope after going through this post, you understand how to calculate the volume of an ellipsoid 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.