I am currently studying C and want to check the correctness of my understanding of the loop for
.
Does the conclusion appear A is 6
, because after the 5th cycle of the cycle, adding +1 to a
(which makes it 6) is done, and then the condition stops because it is no longer <= 5
?
int a;
float b;
b = 0;
for (a = 1; a <= 5; a++)
b = b + 0.5;
printf ("A is %d\t\t B is %.2f\n", a, b);
Exit
A is 6 B is 2.50
source
share