Quiz on second week's material.
Question 1: Given the following code, which options listed are valid type names?
typedef struct foo { int x; } baz;
Select all that apply
Question 2: What does the following code print? (do not run the code: trace it by hand).
void main(void) {
int i = 0, j = 0, k = 0;
i = 1;
Start:
goto L1;
L2:
j = i+k;
goto L3;
L1:
k += 2;
if (i < j) goto L3;
goto L2;
L3:
printf("%d %d %d\n", i, j, k);
}
Your answer should be either three numbers separated by spaces or the word ERROR
if there is an error or it prints nothing.
Question 3: In the C standard, what is the difference between "undefined behavior" and "implementation defined behavior"?
Question 4: Which of the following behave differently (result in different bits in their answers) when applied to signed
vs. unsigned
values?
Select all that apply
Question 5: If x
and y
are int
values, what is the largest possible number of bits that could be set in z
by the assignment z = (!x)&(~y);
?
Question 6: Which of the following are equivalent to !!x
?
Select all that apply