PROGRAMMING FUNDAMENTALS 5.1
FUNCTION A function is a block of code that performs a particular task. There are times when we need
to
write a particular block of code for more than once in our program. This may lead to bugs and irritation for the programmer. C language provides an approach in which you need to declare and define a group of statements once and that can be called and used whenever required. This saves both time and space. C functions can be classified into two categories; predefined functions and user-defined functions.
5.1.1 Category of Function Already have a definition in header files (.h files like stdio.h), so we just call them whenever there is a need to use them. Example: puts(), gets(), printf(), scanf()
• User customize functions • Made for code reusability and for saving time and space.
PRE-DEFINED FUNCTION
USER-DEFINED FUNCTION
5.1.2 Objectives of The Function
To improve the reusability of the code. Debugging of the code would be easier if you use functions, as error are easy to be traced. Reduces the size of the code, duplicate set of statements are replaced by function calls.
51 | P a g e