C Programming Code Examples C > Functions Code Examples find diameter, circumference and area of circle using function find diameter, circumference and area of circle using function Write a C program to input radius of circle from user and find diameter, circumference and area of the given circle using function. How to find diameter, circumference and area of a circle using function in C programming. Declare functions to find diameter, circumference and area of circle First assign a meaningful name to all the three functions. Say function to calculate diameter, circumference and area are - getDiameter(), getCircumference() and getArea() respectively. All the above three functions uses one input i.e. radius of circle to calculate output. Hence all the three function must accept a parameter of double or int type. Finally, all the three functions returns either double or int as output. Hence, return type of the function must be either double or int. #include <stdio.h> #include <math.h> // Used for constant PI referred as M_PI /* Function declaration */ double getDiameter(double radius); double getCircumference(double radius); double getArea(double radius); int main() { float radius, dia, circ, area; /* Input radius of circle from user */ printf("Enter radius of circle: "); scanf("%f", &radius); dia = getDiameter(radius); // Call getDiameter function circ = getCircumference(radius); // Call getCircumference function area = getArea(radius); // Call getArea function 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; } /* Calculate diameter of circle whose radius is given */ double getDiameter(double radius) { return (2 * radius); } /* Calculate circumference of circle whose radius is given */ double getCircumference(double radius) { return (2 * M_PI * radius); // M_PI = PI = 3.14 ... } /* Find area of circle whose radius is given */ double getArea(double radius) { return (M_PI * radius * radius); // M_PI = PI = 3.14 ... }