7. A) Demonstrate the use of C user-defined functions with a suitable example.
Answer:-
User-defined functions are written by programmers to serve their own purpose and are
not readily available.
Functions based modular programming is advantageous in many ways:
- Managing huge programs and software packages is easier by dividing them into functions/modules—Maintenance is easier
- Error detection is easier—Debugging is easier
- Functions once written can be reused in any other applications – Reusability is enhanced
- We can protect our data from illegal users—Data protection becomes easier
Following block diagram explains how functions are useful:Instead of writing entire program (to add and subtract) within main( ) function we can write independent modules add( ) and subtract( ) as shown: