C Programming - Lecture 5
C Programming - Lecture 5
1/38
Index
§ Function § Types of user-defined functions
§ No Argument Passed and No
§ Types of functions Return value
§ User-defined § No Argument Passed But Return
function Value
§ Function § Argument Passed But No Return
prototypes Value
§ Calling Function § Argument Passed and Returns a
§ Function Definition Value
§ Passing arguments § Recursion
to a function § Storage class
§ Return Statement § automatic
§ external
§ static
§ register
2/38
What is Function? (1/2)
3/38
What is Function? (2/2)
4/38
Types of Function
Library functions
These are the built in functions of of ‘‘C’’ library. These are
already defined in header files
e.g. printf ( ); is a function which is used to print at output.
It is defined in‘‘stdio.h’’
5/38
How user-defined function works
6/38
Advantages of user-defined function
7/38
Example: C user-defined functions
8/38
Function prototype (1/2)
9/38
Function prototype (2/2)
10/38
Calling Function
11/38
Function Definition
12/38
Passing arguments to a function
13/38
Return Statement
14/38
Syntax of return statement
For Example:
15/38
Types of user-defined functions
16/38
No Argument Passed and No Return
Value
17/38
No Argument Passed and but Return
Value
18/38
Argument Passed and But No Return
Value
19/38
Argument Passed and Return Value
20/38
C Recursion
21/38
How Recursion Works
22/38
Recursion Example
23/38
Explanation:
24/38
Storage Class
25/38
Storage Class: Automatic/Local
26/38
Storage Class: Automatic (Example)
27/38
Storage Class: External/Global
28/38
Storage Class: External (Example)
29/38
Storage Class: Register
31/38
Storage Class: Register with pointer
variables
§ A register can have address of a memory location.
32/38
Storage Class: Register not with
static
§ C doesn’t allow multiple storage class specifiers for
a variable.
§ So, register can not be used with static
33/38
Storage Class: Register only within
a block
34/38
Storage Class: Static
For example:
static int i;
35/38
Storage Class: static (Example)
Output:
6 11
36/38
Thank You
37/38
References
https://www.programiz.com/c-programming/c-storage-class
https://www.geeksforgeeks.org/understanding-register-keyword/
https://www.tutorialspoint.com/register-keyword-in-c
38/38