Variable: Stores data.
Function: Performs operation on data.
Function takes input, performs operations and returns output
Syntax | Example |
int identity(arguments) { -> statements; } | int add(int a, int b) { int res = a+b ; return res ; } |
C functions classified into:
- Built In Functions
- User Defined Functions
Built in Functions:
- C library is a set of header files
- Header file is a collection of pre-defined functions.
stdio.h | conio.h | string.h | graphics.h |
printf() scanf() feof() … | getch() clrscr() getche() …. | strlen() strrev() strcat() ….. | line() circle() bar() … |
Custom Functions: Programmed defined functions based on application requirement
Calculator.c | Mobile.c | Account.c |
add() subtract() multiply() divide() | call() message() store() ….. | deposit() withdraw() …. |
Every function consists
- Prototype:
- Prototype is called function declaration. Every Custom function must be specified before main().
- Definition:
- Definition is a block of instructions contains function logic. Function executes when we call that function.
- Function call:
- It is a statement and it is used to execute the function logic.
