Introduction to function in C Language


Introduction to function

It is defined as named block of statements .


  1. It is very easy to locate and correct errors .
  2. It reduces complexity of code.
  3. Testing of a program becomes easier.
  4. Bigger softwares problems can be divided into smaller sections using functions.
  5. Functions can be reused.
  6. It is simple to understand a function based program.
  7. Memory can be used very efficiently.
  8. Functions reduce un-ncessary repetition of code.

Creating a function

The syntax for creating a function is

Type Fname(Parameters)
Variables ;
return( Value );


Type is the data types of value returned by function.

Fname is the  functions name  specified by the programmer.

Parameters are variables declared within parenthesis written after the function name. These variables are called parameters

Variables are declared within function body.

Statements is set of  instructions which would run when function is called.

return is used to return a value from function.

Value is any valid variable, constant or expression. The return type of function will depend upon it. If it is of float type, the return type would be int and so on.

Best Books of C

Lesson tags: advantages of function in c, components of a function in c language, Defining a function in c language, Syntax of function in c language, what is a function in c
Back to: C Programming Language