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

Consider the following function

void find (int x)
{
int i, j;
for (i = 0, j =0; i <2, j <4; i++, j++);
x = i + j *x;
printf("%d", x);
}
What will be the output of find (2)?

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

The correct option is A 12

find (2)––––––––:
i = 0, j = 0 0 < 2, 0 < 4
i = 1, j = 1 1 < 2, 1 < 4
i = 2, j = 22 < 2, 2 < 4 (only 2 < 4 considered)
i = 3, j = 3 3 < 3, 3 < 4
i = 0, j = 44 < 3, 4 < 4 (now 4 < 4 fails)

After loop termination, i = 4, j = 4
x = i +j *x x = 4 + 4 * 2
x = 12
12 will be printed by the given function.


flag
Suggest Corrections
thumbs-up
0
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Fear of the Dark
QUANTITATIVE APTITUDE
Watch in App
Join BYJU'S Learning Program
CrossIcon