Coupon Accepted Successfully!


Inputting Default Arguments

Default arguments are used when function is invoked with fewer arguments than declared. The default values are placed in function prototype or function declarator. It is also possible to directly invoke user-defined function in function prototype or function declarator. The return value of function is considered as default value. The following program illustrates this point:

7.15 Write a program to enter default values using function.

Explanation: In the above program, user-defined functions display() and input() are declared and defined. The display() function is used to display passed integer on the screen. The input() function when executed asks for an integer. The function input() is used as default value for function display(). When a function display() is invoked without argument, the input() function assigned as default argument in function prototype is executed. User enters a number. The entered number is then passed on to display() function and displayed on the screen.

Test Your Skills Now!
Take a Quiz now
Reviewer Name