0% found this document useful (0 votes)
3 views

Lec 11 Functions

Chapter 8 of 'Let Us C' discusses functions in C programming, defining them as self-contained blocks of statements that perform specific tasks. It explains that a C program must contain a main() function, which is the entry point for execution, and that functions can call each other and can be recursive. The chapter also distinguishes between library functions and user-defined functions, noting that both types are called in the same manner.

Uploaded by

Abdullah Abbasi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Lec 11 Functions

Chapter 8 of 'Let Us C' discusses functions in C programming, defining them as self-contained blocks of statements that perform specific tasks. It explains that a C program must contain a main() function, which is the entry point for execution, and that functions can call each other and can be recursive. The chapter also distinguishes between library functions and user-defined functions, noting that both types are called in the same manner.

Uploaded by

Abdullah Abbasi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

03/28/2022

CHAPTER 8: FUNCTIONS
BOOK: LET US C

 A function is a self-contained block of statements that


perform a coherent task of some kind

1
03/28/2022

 Output:

A number of conclusions can be drawn from this program:


 A C program is a collection of one or more functions.
 If a C program contains only one function, it must be main( ).
 If a C program contains more than one function, then one (and only one) of
these functions must be main( ), because program execution always begins
with main( ).
 There is no limit on the number of functions that might be present in a C
program.
 Each function in a program is called in the sequence specified by the
function calls in main( ).
 After each function has done its thing, control returns to main( ). When
main( ) runs out of statements and function calls, the program ends.

2
03/28/2022

 Functions can call each other

 Output:

 A function can be called any number of times

3
03/28/2022

 The order in which the functions are defined in a program and the order in
which they get called need not necessarily be same

 A function can call itself. Such a process is called


‘recursion’. We would discuss this aspect of C functions
in Chapter 10.
 A function can be called from another function, but a
function cannot be defined in another function.

4
03/28/2022

 There are basically two types of functions:


1. Library functions Ex. printf( ), scanf( ), etc.

2. User-defined functions Ex. argentina( ), brazil( ), etc.

 As the name suggests, library functions are nothing


but commonly required functions grouped together and
stored in a Library file on the disk.
 These library of functions come ready-made with
development environments.
 The procedure for calling both types of functions is
exactly same.

You might also like