C Functions

C Functions Declaration

A function declaration tells the compiler about a function name and how to call the function.

The actual body of the function can be defined separately.


A function declaration has the following parts –

   returnType functionName (parameterList);


A function declaration in C consists of:

  1. Return type
  2. Function name
  3. Parameter and argument

Calling a Function

While creating a C function, you give a definition of what the function has to do. To use a function, you will have to call that function to perform the defined task.


When a program calls a function, the program control is transferred to the called function. A called function performs a defined task and when its return statement is executed or when its function-ending closing brace is reached, it returns the program control back to the main program.


To call a function, you simply need to pass the required parameters along with the function name, and if the function returns a value, then you can store the returned value.


#include <stdio.h>

/* function declaration */
int max(int num1, int num2);

int main () {

   /* local variable definition */
   int a = 100;
   int b = 200;
   int ret;

   /* calling a function to get max value */
   ret = max(a, b);

   printf( "Max value is : %d\n", ret );

   return 0;

/* function returning the max between two numbers */
int max(int num1, int num2) {

   /* local variable declaration */
   int result;

   if (num1 > num2)
      result = num1;
      result = num2;

   return result;


Please Share this page
Views : 56
Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!