C – Functions

Variable: Stores data.

Function: Performs operation on data.

Function takes input, performs operations and returns output

SyntaxExample
            int identity(arguments)
            {
                        -> statements;
            }
            int add(int a, int b)
            {
                        int res = a+b ;
                        return res ;
            }

C functions classified into:

  1. Built In Functions
  2. User Defined Functions

Built in Functions:

  • C library is a set of header files
  • Header file is a collection of pre-defined functions.
stdio.hconio.hstring.hgraphics.h
printf()
scanf()
feof()
getch()
clrscr()
getche()
….
strlen()
strrev()
strcat()
…..
line()
circle()
bar()

Custom Functions: Programmed defined functions based on application requirement

Calculator.cMobile.cAccount.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.

Scroll to Top