int a b c 0 for a 0 a SolutionCODE SNIPPET1 include int ma
Solution
CODE SNIPPET-1
#include <stdio.h>
int main()
{
int a,b,c=0;
for(a=0;a<4;a++)
for(b=0;b<a;b++) {
if(a+b > 3)
break;
m++;
}
printf(\"m=%d\ \",m);
return 0;
}
From the above code snippet, it raises a compile time error because the value of \"m\" was un declared
For the above code if variable m is declared as 0, like : int m=0, then
Then the output will print m=4, because the loop will iterate for four times, such that incrementing value of m as m++.
SNIPPET-2
#include <stdio.h>
int main()
{
int j=3,k=1,m;
for(m=0;m<j;m++){
if(++k > j)
continue;
printf(\"j : %d k : %d m: %d\ \",j, k, m);
}
return 0;
}
From the above example snippet code, it is observed that the loop starts with m=0 to m<3,
When m= 0, then m < j is true 0 < 3
Then ++K > j is false because, 2>3 is false, so it prints, j : 3 k : 2 m: 0
Now, again m is incremented, m=1, k=2, j=3
++k > j is again false, because 3 > 3 is always false, so it prints: j : 3 k : 3 m: 1
Again m is incremented to m =2, k=3, j=3
Then, ++k > j is true, because 4>3, so loop will exit from current iteration and continue
Again m is incremented to m =3, k=3, j=3
Then, m < j in loop fails, because 3 < 3 always false, Hence loop will stop iterating and prints below output
OUTPUT:
j : 3 k : 2 m: 0
j : 3 k : 3 m: 1

