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;
}
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: