Use of Subroutines
Sample program : use of subroutines So far, we have used only printf function that has been provided by the C system. The program shown in following program uses a user-defined function. A function defined by the user is equivalent to a subroutine in FORTRAN or subprogram in BASIC. This program presents a very simple program that uses a mul( ) function. The program will print the following output. Multiplication of 5 and 10 is 50 The mul( ) function multiplies the values of x and y and the result is returned to the main( ) function when it is called in the statement. c = mul ( a, b ) ; The mul ( ) has two arguments x and y that are declared as integers. The values of a and b are passed on to x and y respectively when the function mul ( ) is called.