Page 4 - Sample_test_Float
P. 4
4 Functions and Pointers
Consider the following example:
2,3 add 5
3,4 add 7
4,5 add 9
5,6 add 11
6,7 add 13
In the above illustration only the input and output arechanging, but the function add remains constant.
So we need not write add the function again and again, instead we can write the add function only once and
call it again with different sets of inputs.
2,3 add 5
3,4 add 7
4,5 add 9
5,6 add 11
6,7 add 13
5.1.3. Advantages of Writing Function
1. Modular and Structural Programming
• We can divide c program into smaller modules.
For example:A calculator program can be divide into four modules such as add,subtract,multiply
and divide.
• We can call these modules whenever required.
• Modules once created can be re-used in other programs.
2. Individual functions can be built independently without any ambiguity.
3. More than one module can be developed parallelly.
4. Testing can be done effectively when we test individual modules rather than testing the entire program.
5. Frequently used functions can be put together in the customized library.
• Frequently used functions can be put in our custom header file and it can be included in other
programs too.

