Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Function

Function is small manageable and function unit of a program which performs certain
task in the program. Functions are used to divide a large C program into smaller
parts.
Syntax of it goes like this:

return_type function_name ( data_type parameter1, data_type parameter2,..) {


// code to be executed;
}

Advantages of Using Function


-More Programmers can work on a single program.
-Software development process becomes faster.
-Easy to Debug

*The two types of function are: Library Function and User-defined Function

Function Prototype
Function prototype is the function declaration w/o the body before the main( )
function.
Ex.

void hello ( char[ ], int ); // function prototype


int main ( ) {
// ..
}
void hello ( char name[ ], int age ) {
printf(“Hello %s! You are %d years old.”, name, age );
}
-Function prototype helps to navigate to main( ) function easily .

Recursive Function
Recursive function is the function that calls itself again and again. The best example
of recursive function is the factorial program.

You might also like