DIY C Program on Area of a Circle(http://www.bloggerspot.tk)



Area of a Circle

DIY C Program on Area of a Circle(http://www.bloggerspot.tk)


Write a program to find the area of a circle using functions.

Function:
float calcarea(float x)

Input Format:
Input consists of 1 floating point number which corresponds to the radius of the circle.

Output Format:
Output consists of a single floating point number (correct to 2 decimal places). Refer sample output for
formatting details.
Take the value of pi as 3.14.

Sample Input:
3

Sample Output:
The area of the circle is 28.26

Solution:

#include <stdio.h>
float calcarea (float x);
int main()
{
int x;
float a;
scanf("%d", &x);
a = calcarea (x);
printf("The area of the circle is %.2f\n", a);
return 0;
}
float calcarea (float x)
{
float res;
res = ((x * x) * 3.14);
return res;
}

1 comment:

  1. It's the best time to make some plans for the long run and it is time to be happy. I have learn this publish and if I may just I wish to counsel you some interesting things or tips. Perhaps you could write next articles referring to this article. I want to read more issues approximately it!
    seo in philippines

    ReplyDelete

Your Comments here.

© Copyright 2015. Website by Way2themes - Published By Gooyaabi Templates