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)?
find (2)––––––––––:
i = 0, j = 0 ⇒ 0 < 2, 0 < 4
i = 1, j = 1 ⇒ 1 < 2, 1 < 4
i = 2, j = 2⇒2 < 2, 2 < 4 (only 2 < 4 considered)
i = 3, j = 3 ⇒ 3 < 3, 3 < 4
i = 0, j = 4⇒4 < 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.