-
Consider the C function given below.
int f(int j)
{
static int i = 50;
int k;
if (i == j)
{
printf(“something”);
k = f(i);
return 0;
}
else return 0;
}
Which one of the following is TRUE ?
-
- The function returns 0 for all values of j.
- The function prints the string something for all values of j.
- The function returns 0 when j = 50.
- The function will exhaust the runtime stack or run into an infinite loop when j = 50.
- The function returns 0 for all values of j.
Correct Option: D
When j = 50, j (50), the function goes to an infinite loop by calling f(i) recursively for i = j = 50