Rewrite each one in a way that makes sense to you.
1.
Code:
int arr[] = {5,6,7,8,9,10};
int x = 1;
int *p = &arr[2]; // p points to the 7
p--; // p points to the 6
x = p[x] // p[1] points to the element one spot after the 6
So x is 7, like you would expect. Notice &arr[2] is the same as arr + 2
2. A general for loop... for(INIT; COND; INCR) STAT; can be rewritten as
Code:
INIT;
while (COND) {
STAT;
INCR;
}
So, using this transformation, your for loop is the same as
Code:
i = 3;
while (i != 15)
i = i + 2;
So the final value is 15. It says in English "Start the loop at i=3. Loop until i becomes 15, then stop. Each time through the loop, increment i by 2"
3. An expression like VAR++ is the same as saying this:
VAR;
VAR = VAR + 1;
So rewrite your third snippet like this
Code:
int r = -1 ;
while (r) {
r = r + 1;
printf("r = %d \n", r);
}
r = r + 1;