C Program to Find Area of Ellipse

In this post, we will learn how to find the area of an ellipse using C Programming language.

The area of an ellipse is defined as the amount of region present inside it. 

  • Area of Ellipse = π a b,

where,
a = length of semi-major axis
b = length of semi-minor axis

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

C Program to Find Area of Ellipse

// C Program to Find Area of Ellipse
#include <stdio.h>
#define PI 3.14 
int main(){
    float major, minor, area;
    
    // Asking for input
    printf("Enter the minor axis: ");
    scanf("%f", &minor);
    printf("Enter the major axis: ");
    scanf("%f", &major);
    
    // Calculating area of ellipse
    area = PI * minor * major;
    
    // Displaying output
    printf("Area of Ellipse: %.2f", area);
    return 0;
}

Output

Enter the minor axis: 7
Enter the major axis: 15
Area of Ellipse: 329.70

How Does This Program Work ?

    float major, minor, area;

In this program, we have declared three float data type variables named major, minor and area.

    // Asking for input
    printf("Enter the minor axis: ");
    scanf("%f", &minor);
    printf("Enter the major axis: ");
    scanf("%f", &major);

Then, the user is asked to enter the value of the major axis and minor axis.

    // Calculating area of ellipse
    area = PI * minor * major;

We calculate the area using the formula π a b, where,
a = length of semi-major axis
b = length of semi-minor axis
Π – 3.14

    // Displaying output
    printf("Area of Ellipse: %.2f", area);

Finally, the area is printed using the printf() function. Here, we have used %.2f format specifier because we want to display the output only till 2 decimal places.

Conclusion

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