Chapter 1.3 - Illustrate the use of user-defined functions and math functions through sample programs | Part - 1
SAMPLE PROGRAM 4: USE OF SUBROUTINES
So far, we have used only printf function that has been provided for us by the C system. The program is shown in Fig. 7 uses a user-defined function. A function defined by the user is equivalent to a subroutine in FORTRAN or subprogram in BASIC.
Chapter 1 - History of C Programming Language
Chapter 1.1 - Produce an overview of C Programming
Chapter 1 - History of C Programming Language
Chapter 1.1 - Produce an overview of C Programming
Fig. 7 present a very simple program that uses a mul() function. The program will print the following output.
Download Let us C E-BOOK | Yashwant Kanetkar
Download Turbo C++ Program Compiler
Download Let us C E-BOOK | Yashwant Kanetkar
Download Turbo C++ Program Compiler
Multiplication of 5 and 10 is 50
![]() |
Fig. 7 A program using a user-defined function |
The mul() function multiplies the value of x & y and the result is returned to the main() function when it is called in the statement
c = mul(a,b);
Chapter 1.2 - Exemplify the elementary C concept through sample Programs
PART - 1
PART - 2
PART - 3
Chapter 1.2 - Exemplify the elementary C concept through sample Programs
PART - 1
PART - 2
PART - 3
The mul() has two arguments x and y that are declared as an integer. The values of a and b are passed on to x and y respectively when the function mul() is called. User-defined functions are considered in detail in another our post #allaboutprogramming62.
Comments
Post a Comment
Ask Me Everything About Programming.