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

Consider the program below:
# include <stdio.h>
int fun (int n, int *f_p) {
int t, f;
if(n< =1){
*f_p = 1;
return 1;
}
t = fun(n-1, f_p);
f = t +* f_p;
*f_p = t:
return f ;
}
int main()
{
int x = 15;
printf (“% d\n”, fun (5, &x)) ;
return 0;
The value printed is

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

The correct option is C 8
x = 15
fun (5, &x) let &x = 100

fun (5, 100)
t =5, f = 5 + 3, *f_p =5
return 8
fun (4, 100)
t = 3, f = 3 + 2, *f_p = 3
return 5
fun (3, 100)
t = 2, f = 2 + 1, *f_p = 2
return 3
fun (2, 100)
t = 1, f = 1 + -1, *f_p = 1
return 2
fun (1, 100)
*f_p = 1
return 1
So fun (5, & x) will return 8 and it will be printed.

flag
Suggest Corrections
thumbs-up
0
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Heat Capacity
CHEMISTRY
Watch in App
Join BYJU'S Learning Program
CrossIcon