Functions II-221
A return statement can return only one value. We may include an expression within return statement.
In that case, first, the expression is evaluated, then the value is returned.
18. What is a global pointer? Illustrate with a suitable example.
Ans: If we define a pointer above main() function, it will become a global pointer. The scope of
this pointer is throughout the program. We can use this pointer in any part of the program.
19. Why is the return statement not necessary when a function is called by a reference?
Ans: When we pass the arguments by reference, any changes in formal arguments are reflected in
actual arguments; therefore, we need not to return any value from the called function. The function can
be called by reference by passing the address of the arguments to the function.
20. Distinguish between function prototype and function definition.
Ans: The function prototype informs the compiler about the function name, its argument and return
type. The function prototype can be given globally or local to main(). However, the function prototype
must precede function call if the function is not defined before the function call.
The function definition is the actual definition of the function; it also contains function prototype
below which the function body is given.
21. Does the function prototype match with the function definition?
Ans: The function prototype is declared to inform the compiler about function. The function proto-
type and function definition may have different variable names, but their types must match with each
other.
22. Can we define a user-defined function with the same library function name?
Ans: In C language, we cannot define the function with the same name as library function, because
on doing so, we will get error due function redeclaration.
23. What is recursion? Explain its advantages.
Ans: When a function invokes itself from its own function body, it is called recursion. The recursions
are of two types, which are direct recursion and indirect recursion. In the direct recursion, the same func-
tion calls itself from its own body. In indirect recursion, the function invokes some other function, which
again invokes the function that has invoked it. That is, it creates a cycle of function calls. Recursion can
be used to reduce the code length in some special types of problems. These problems become simpler
when coded with recursion than iterative approach.
24. Explain the types of recursions.
Ans: The recursions are of two types, which are direct recursion and indirect recursion. In the direct
recursion, the same function calls itself from its own body. In indirect recursion, the function invokes
some other functions, which again invokes the function that has invoked it. That is, it creates a cycle of
function calls.
25. Is it possible to call library function recursively?
Ans: As we know that we cannot edit the code of the library functions; the library function are not
recursive previously, so we cannot call them recursively.
M10_ITL-ESL4791_02_SE_C10.indd 221 12/22/2012 5:01:42 PM