C
Chad
The question is about the following C code...
[cdalten@localhost oakland]$ more loopy.c
#include <stdio.h>
int main(void)
{
int i;
for (i = 0; i < 5; i++) {
if (i == 3)
break;
printf("The value of i inside the loop is is: %d\n", i);
}
printf("The value of i is: %d\n", i);
return 0;
}
[cdalten@localhost oakland]$ ./loopy
The value of i inside the loop is is: 0
The value of i inside the loop is is: 1
The value of i inside the loop is is: 2
The value of i is: 3
[cdalten@localhost oakland]$
The way I understand it, when i =2, the value will get incremented to
a value of three (via i++ in the for loop). The question is, how come
the value of i in ...
printf("The value of i inside the loop is is: %d\n", i);
doesn't get effected by the increment? Ie, how can it retain the
previous value after i has been incremented to a value of 3.
[cdalten@localhost oakland]$ more loopy.c
#include <stdio.h>
int main(void)
{
int i;
for (i = 0; i < 5; i++) {
if (i == 3)
break;
printf("The value of i inside the loop is is: %d\n", i);
}
printf("The value of i is: %d\n", i);
return 0;
}
[cdalten@localhost oakland]$ ./loopy
The value of i inside the loop is is: 0
The value of i inside the loop is is: 1
The value of i inside the loop is is: 2
The value of i is: 3
[cdalten@localhost oakland]$
The way I understand it, when i =2, the value will get incremented to
a value of three (via i++ in the for loop). The question is, how come
the value of i in ...
printf("The value of i inside the loop is is: %d\n", i);
doesn't get effected by the increment? Ie, how can it retain the
previous value after i has been incremented to a value of 3.