In the Mini project, 3rd function is to find the area of a circle. Rita allotted this function to Suganya.
Help Suganya to write a program to find the area of a circle using functions.
Function Specification:
float calcarea(float x);
Input Format:
Input consists of 1 floating point number which corresponds to the radius of the circle.
Output Format:
The output consists of a single floating point number (correct to 2 decimal places).
Take the value of pi as 3.14.
Refer sample input and output for formatting details.
Sample Input:
3
Sample Output:
The area of the circle is 28.26
Program Code:
#include <stdio.h>
const float PI = 3.14;
float calcarea(float radius);
int main()
{
float radius;
scanf("%f", &radius);
printf("The area of the circle is %.2f", calcarea(radius));
return 0;
}
/* return area of a circle */
float calcarea(float radius)
{
return PI * radius * radius;
}
Post A Comment:
0 comments: