Homework E6

Due dates

This assignment must be submitted as a single file named ellipse.c to the Moodle submission page for Homework E6 by 11:00 PM on Tuesday, 4 October.

The assignment

In this assignment you will write a simple function that satisfies the following prototype which must be stored in your NetBeans project as ellipse.h.

/* 
 * Author: J Dean Brock
 * Prototypes for Homework 6
 *
 * DO NOT CHANGE THIS FILE!
 */

#ifndef ELLIPSE_H
#define	ELLIPSE_H

double ellipseArea(int width, int height) ;

#endif	/* ELLIPSE_H */

You are to implement the function ellipseArea in a file called ellipse.c. The function ellipseArea is passed the width and height of an ellipse. If either of these parameters is negative, your function should return -1. Otherwise, your function should return the area of the ellipse, width×height×π/4.

Your function should do no I/O. To test it, run the main function stored in the driver file main.c.

Your file ellipse.c should be very short. It should start with an #include of ellipse.h followed by the function ellipseArea which should be about a half dozen lines long. This assignment is really not about writing an interesting function. It is about setting up NetBeans to write a function stored in an external file.

Amazingly, ISO C does not provide the common mathematical constants. Use 0.78539816339744830962 for π/4.

To verify that your program is correct, compare your output with my output.