1. FUNCTIONS IN C LANGUAGE SRN:R22DE170
M a s t e r o f C o m p u t e r A p p l i c a t i o n
1 s t S e m e s t e r 2 0 2 2
S chool of Compute r science and Applicat ion
2. Functions in C language
P r e s e n t e d B y :
V a r u n H D S R N : R 2 2 D E 1 7 0
S u b m i t t e d t o :
P r o f . L o k e s h
3. 1. What is C function?
2.Types of C functions
3. Uses of C functions
4. Advantage of C functions
3
4. 4
• What is C Function?
• A function is a group of statements that together
perform a task.
C functions are basic building blocks in a program.
• A large C program is divided into basic
building blocks called C function. C function contains set of
instructions enclosed by “{ }” which performs specific
operation in a C program. Actually, Collection of these
functions creates a C program
6. 6
• Standard Library Functions:
Library functions in C language are inbuilt functions which are grouped
together and placed in a common place called library. Each library
function in C performs specific operation.
• The standard library functions are built-in functions in C programming
to handle tasks such as mathematical computations, I/O processing,
string handling etc.
• These functions are defined in the header file. When you include the
header file, these functions are available for use. For example:
• The printf() is a standard library function to send formatted output to
the screen (display
output on the screen). This function is defined in "stdio.h" header file.
7. 7
➤ There are other numerous library functions defined under "stdio.h", such as
scanf(), printf(), getchar() etc. Once you include "stdio.h" in your program, all
these functions are available for use.
User-defined Functions:
As mentioned earlier, C allow programmers to define functions. Such functions
created by the user are called user-defined functions.
Depending upon the complexity and requirement of the program, you can
create as many user-defined functions as you want.
8. 8
• These are classified into 4 types of functions:
1. Functions with arguments and return values. This function has arguments and returns a
value: ...
2. Functions with arguments and without return values. ...
3. Functions without arguments and with return values. ...
4. Functions without arguments and without return values.
9. 9
• Uses of C functions:
• C functions are used to avoid rewriting same logic/code again
and again in a program.There is no limit in calling C functions to make use
of same functionality wherever required.
• We can call functions any number of times in a program and
from any place in a program.A large C program can easily be tracked when
it is divided into functions.
• The core concept of C functions are, re-usability, dividing a big
task into small pieces to achieve the functionality and to
improve understandability of very large C programs.
10. 10
ADVANTAGES OF FUNCTIONS
1. It is much easier to write a structured program where a large
program can be divided into a smaller, simpler task.
2. Allowing the code to be called many times
Easier to read and update
3. It is easier to debug a structured program where there error is
easy to find and fix