- What is the output of the following code fragment?
int i;
for (i = 0 ; i < 9 ; i = i + 2) {
printf("%d\n", 2 * i) ;
}
0
4
8
12
16
- Evaluate the following expression. Recall that *,
/ and % have higher precedence than + and -
and all five operators associate left to right.
2 + 7 + 6 * 4 - 5 / 2 + 8 % 3
33
- Predict the output of the following code fragment
int i = 0;
if(i = 1) {
printf ("Pink Floyd");
}
else if (i == 2) {
printf ("Led Zeppelin");
}
else {
printf ("Grateful Dead");
}
Pink Floyd
- What does this print?
int a, b;
a = 11;
b = 27;
a++;
a += b;
b = a - b;
a -= b;
printf("a is %d and b is %d\n", a, b);
a is 27 and b is 12