A function is a block of code that has a name and it has a property that it is reusable i.e. it can be executed from as many different points in a C Program as required.

The name of the function is unique in a C Program and is Global. It neams that a function can be accessed from any location with in a C Program. We pass information to the function called arguments specified when the function is called. And the function either returns some value to the point it was called from or returns nothing.

Structure of a Function

There are two main parts of the function. The function header and the function body.

int sum(int x, int y)
               int ans = 0;              //holds the answer that will be returned
               ans = x + y;             //calculate the sum
               return ans                //return the answer

Function Header

In the first line of the above code

int sum(int x, int y)

There are three main parts in function:

  • The name of the function i.e. sum
  • The parameters of the function enclosed in paranthesis
  • Return value type i.e. int

Types of Functions

  • Functions with no arguments and no return values.
    A C function without any arguments means you cannot pass data (values like int, char etc) to the called function. Similarly, function with no return type does not pass back data to the calling function.
  • Functions with arguments and no return values.
    In this “main()” function has no control over the UDF “printfline()”, it cannot control its output. Whenever “main()” calls “printline()”, it simply prints line every time. So the result remains the same.
  • Functions with arguments and return values.
    This type of function can send arguments (data) from the calling function to the called function. After that that will wait for the result to be returned back from the called function back to the calling function. This type of function is mostly used in programming world because it can do two way communications; it can accept data as arguments as well as can send back data as return value.
  • Functions that return multiple values.
    This type of function which does not take any argument but only returns values to the calling function then this type of function is useful.
  • Functions with no arguments and return values.
    Return statement used to return only single value. Return statement can return only one value. But if we want to send back more than one value then how we could do this?
    We have used arguments to send values to the called function, or we can also use arguments to send back information to the calling function. The arguments that are used to send back data are called Output Parameters

The reference site for this content is and