Circle Facts

This is a warmup exercise. It is not compulsory, and may be completed individually or with your lab partner.

You are given a main function and function prototypes to implement to calculate facts about a circle, given its radius. Copy the program circleFacts.c from the course account to your week 4 directory by typing (make sure you type the dot at the end):

$ cp /web/cs1511/17s2/week04/files/circleFacts.c .

The three functions to implement are:

double area(double radius);
double circumference(double radius);
double diameter(double radius);

You must use the #define‘d value of pi.

Some Examples

Enter the radius: 1
Area          = 3.14
Circumference = 6.28
Diameter      = 2.00
Enter the radius: 17
Area          = 907.46
Circumference = 106.76
Diameter      = 34.00
Enter the radius: 7.2
Area          = 162.78
Circumference = 45.22
Diameter      = 14.40

To run some simple automated tests:

$ 1511 autotest circleFacts

To run Styl-o-matic:

$ 1511 stylomatic circleFacts.c
Looks good!

You’ll get advice if you need to make changes to your code.

Submit your work with the give command, like so:

$ give cs1511 wk04_circleFacts

Or, if you are working from home, upload the relevant file(s) to the wk04_circleFacts activity on Give Online.