Return to course page

Unlike most quizzes, you may work together, browse the web, run code, etc. when doing this quiz.

Question 1: Which of the following C++ elements are also in C?
Select all that apply

  1. new and delete

  2. pointers with & and *

  3. a->b as shorthand for (*a).b

  4. pass-by-reference with &

Question 2: There are many flavors of C. Some of our tool-chains will expect strict ANSI-compliant C. You can get this version by running gcc -ansi -pedantic-errors or clang -ansi -pedantic-errors. How does this standard differ from C++?
Select all that apply

  1. /* */ is not a comment in ANSI C

  2. // is not a comment in ANSI C

  3. int a, b=3; does not compile in ANSI C

  4. for(int i = 0; i < 5; i += 1) {} does not compile in ANSI C

Question 3: Consider the following code

int x[4];
int *y = &x[0];

Which one of the following expressions has different semantics for x than it does for y?

  1. _[2]

  2. sizeof(_)

  3. _ + 2

  4. *_

Question 4: How many ints fit inside x if x is declared as int *x = malloc(8);? Answer as an integer (in the usual base-10 notation).

Answer:
Return to main page
Return to course page