In C programming language, the behavior of J increment when it reaches zero depends on the type of loop being used.
Example:
int J = 10;
while(J >= 0) {
printf("%d\n", J);
J--;
}
printf("J has reached zero\n");
Output:
10
9
8
7
6
5
4
3
2
1
0
J has reached zero
Example:
for(int J = 10; J >= 0; J--) {
printf("%d\n", J);
}
printf("J has reached zero\n");
Output:
10
9
8
7
6
5
4
3
2
1
0
J has reached zero
In both cases, the loop reaches its termination condition and stops executing. However, the behaviors depend on when the condition is evaluated.
Asked: 2023-05-07 05:05:29 +0000
Seen: 9 times
Last updated: May 07 '23