Discussion :: Control Structures
-
What will be the value of i and j after execution of following program?
#include<stdio.h>
void main()
{
int i, j;
for(i=0,j=0;i<10,j<20;i++,j++){
printf("i=%d %t j=%d", i, j);
}
}
Answer : Option C
Explanation :
comma operator is executed from left to right so until j<20 for loop statement is true, so both i and j are incremented.
So, i = 20 and j = 20.
Be The First To Comment