wiz-icon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

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?

A
The function will exhaust the runtime stack or run into an infinite loop when j = 50.
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
B
The function prints the string something for all values of j
No worries! We‘ve got your back. Try BYJU‘S free classes today!
C
The function returns 0 for all values of j.
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
The function returns 0 when j = 50.
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution

The correct option is A The function will exhaust the runtime stack or run into an infinite loop when j = 50.
f(50) goes into infinite loop by calling
f(i) recursively for i = j = 50

flag
Suggest Corrections
thumbs-up
0
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Integration as Anti-Derivative
MATHEMATICS
Watch in App
Join BYJU'S Learning Program
CrossIcon