CameraIcon
CameraIcon
SearchIcon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

Consider the following function.
static int x =1;
int find (int a)
{
if (a ==0)
return x ;
else
{
x = x +1;
return find (a - 2);
}
}
void main ()
{
x = find (6);
printf("%d", x);
}
The output of the above program is ________

A
2
No worries! We‘ve got your back. Try BYJU‘S free classes today!
B
5
No worries! We‘ve got your back. Try BYJU‘S free classes today!
C
3
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
4
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
Open in App
Solution

The correct option is D 4
x= /1/2/3 4
( x is static variable)
x =4 in main ( ), So 4 will be printed by the given code

flag
Suggest Corrections
thumbs-up
0
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Geometrical Interpretation
MATHEMATICS
Watch in App
Join BYJU'S Learning Program
CrossIcon