Question: Write a function float circle.area(float r), which takes a radius value and calculates the area of a circle. The correct formula is Pi'r'r, where you

Write a function float circle.area(float r), which takes a radius value and calculates the area of a circle. The correct formula is Pi'r'r, where you can assume that PI=3.1415. You should check if the value for radius is strictly positive. If not, you should return -1

HINT: You should return the value, not printing it.

For example:

Test Output

printf("$.41", circle area (14.5)) 660.5004

printf("%.4f", circle area(-10)) -1.0000

printf("%.4f", circle area(0)) -1.0000

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!