You are on page 1of 6

FUNCTIONS

Function : A function is nothing but a group of statements , it can do some specific task. Advantage : They avoid rewriting the same piece of code again and again at different places. The debugging process becomes simple. Types of functions : Mainly functions are divide into 2 types 1. Library functions or predefined functions eg : - printf(),scanf(),clescr(),getch(). 2. User defined functions or programmer defined functions

Creating a function : syntax : <return value type><fun-name>(parameters list) { body of the function [return <value>]; } Function Definition : It contains the functions return type, name , parameters list and body. Function calling : Transferring control from one function to another function. Called function : A function which gets called. Calling function : A function which calls an another function . Note : - A function can not be defined in any other function.

According to arguments and return values Functions are divided into 3 types.

They are :
1. Function with no arguments and no return values. 2. Function with arguments and no return values 3. Function with arguments and return values.

Recursive Function : A function is said to be a Recursive function when there is a call back to itself. Example: Recursion() { printf("Recursion !"); Recursion(); }

Features : There should be at least one if statement used to terminate recursion. It does not contain any looping statements. Advantages : It is easy to use. It represents compact programming structures. Disadvantages : It is slower than that of looping statements because each time function is called. Note : It can be applied to calculate factorial of a number, Fibonacci series.

You might also like