11 : C Program to Calculate Area of ellipse

Check out the complete list of c-programs : C Program List    



To calculate the area of ellipse you need to know the radius 1 and radius 2 of the eclipse.

Variables :

1. r1 : (Datatype int) : to represent the radius 1 of ellipse.

2. r2 : (Datatype int) : to represent the radius 2 of ellipse.

3. PI : (Datatype float) : static variable to represent constant PI value upto 3 decimal places i.e 3.142

5. area_of_ellipse : (Datatype long) : to store area of ellipse calculated.





Functions :

printf() : is used to display something on the console/screen. Format specifier %d in printf function is used to display a int variable on screen and %ld for long. \n is used to add a newline

scanf() : is used to fetch data inputted by the user on the console/screen using keyboard. %d in scanf is indicates that inputted text is of type int and %ld for long.







Formula :

Volume of Ellipse : π x r1 x r2


/*
 * 1000+ C programs + tutorials
 *
 *
 * 11_calculate_area_of_ellipse.c
 *
 *
 *  Created on: Oct 20, 2014
 *  Author: Code2care.org
 */

#include <stdio.h>
//#include <conio.h>

void main() {

    int r1,r2;
    float PI = 3.142;
	long area_of_ellipse;

//	clrscr();

	printf(" Program to calculate Area of a Ellipse :  \n\n");

	printf(" Enter Radius1 of Ellipse : ");
	scanf("%d", &r1);
    
    
    printf("\n\n Enter Radius2 of Ellipse : ");
	scanf("%d", &r2);
    
    
	area_of_ellipse = PI*r1*r2;


	printf("\n\n Area of Ellipse with radius1 as %d and radius2 as %d = %ld",r1,r2,area_of_ellipse);

//	getch();


}








The best way to learn C programming is to practice more and more of programs . Code2care C Programming tutorials provide 1000+ programs in C that you can study and become an expert in the language. Programs are divided into categories depending upon type and complexity.

BSc. IT, BSc. Computer Science, BSc. IT, MSc. IT, MSc. Computer Science, MCA, BTech IT & BTech Engineers may find these programs very useful.