Calling a function in c – Calling a Function in C Programming

How to call a function in c programming: After writing a function in C, we have to call this function to perform the task defined inside function body. We cannot execute the code defined inside function’s body unless we call it from another function.

When a function(calling function) calls another function(called function), program control is transferred to the called function. A called function performs specific task defined in functions body and when called function terminates either by return statement or when its function-ending closing brace is reached, program control returns back to the calling function.

Syntax to Call a Function

function_name(argument1 ,argument2 ,...);

Calling a function in c: We can call a C function just by passing the required parameters along with function name. If function returns a value, then we can store returned value in a variable of same data type.

For Example
int sum = getSum(5, 7);
Above statement will call a function named getSum and pass 5 and 7 as a parameter. It also stores the return value of getSum function in variable sum.

C Program to call a Function to Calculate Area of Circle

Calling a Function in C Programming

/* Function Defination */
float getAreaOfCircle(float side){
   float area;
   area = 3.141*side*side;
   return area;
int main(){
   float radius, area;
   printf("Enter radius of circle\n");
   scanf("%f", &radius);
   /* Calling getAreaOfCircle function */
   area = getAreaOfCircle(radius);
   printf("Area of Circle = %f", area);
   return 0;

Above program calculates the area of circle in getAreaOfCircle function. We are calling this function inside main function by passing radius as function parameter.


Enter radius of circle
Area of Circle = 153.908997