C Programming - Functions
Exercise : Functions - Yes / No Questions
6.
Usually recursion works slower than loops.
Answer: Option
Explanation:
When a recursive call is made, the function/process clones itself and then process that funtion. This leads to time and space constrains.
In a loop, there is no recursive call involved that saves a lot of time and space too.
7.
Is it true that too many recursive calls may result into stack overflow?
Answer: Option
Explanation:
Yes, too many recursive calls may result into stack overflow. because when a function is called its return address is stored in stack.
After sometime the stack memory will be filled completely. Hence stack overflow error will occur.
8.
In a function two return statements should never occur.
Answer: Option
Explanation:
No, In a function two return statements can occur but not successively.
Example:
#include <stdio.h>
int mul(int, int); /* Function prototype */
int main()
{
int a = 0, b = 3, c;
c = mul(a, b);
printf("c = %d\n", c);
return 0;
}
/* Two return statements in the mul() function */
int mul(int a, int b)
{
if(a == 0 || b == 0)
{
return 0;
}
else
{
return (a * b);
}
}
Output:
c = 0
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers