C Program to Find Diameter, Circumference and Area of Circle Using Function

In this program, we will find diameter, circumference and area of a circle using function.



Source Code
#include <stdio.h>
#include <math.h>
double getDiameter(double radius);
double getCircumference(double radius);
double getArea(double radius);
int main()
{
    float radius, dia, circ, area;
    printf("Enter radius of circle: ");
    scanf("%f", &radius);

    dia  = getDiameter(radius);
    circ = getCircumference(radius);
    area = getArea(radius);

    printf("Diameter of the circle = %.2f units\n", dia);
    printf("Circumference of the circle = %.2f units\n", circ);
    printf("Area of the circle = %.2f sq. units", area);
    return 0;
}
double getDiameter(double radius)
{
    return (2 * radius);
}
double getCircumference(double radius)
{
    return (2 * M_PI * radius); // M_PI = PI = 3.14 ...
}
double getArea(double radius)
{
    return (M_PI * radius * radius); // M_PI = PI = 3.14 ...
}
Output
Enter radius of circle: 12.3
Diameter of the circle = 24.60 units
Circumference of the circle = 77.28 units
Area of the circle = 475.29 sq. units





"Coding Hub - Learn to code" app now available on Google Play Store