Review for Quiz 0

One-page version suitable for printing.

Question 0-1

Consider the following grammar.

  S ->                 (no tokens)
     | a S b S
     | b S a S

Solution

Question 0-2

Consider the following C code.

#include <stdio.h>

int p = 5;

void f(int a, int b) {
    a = 2;
    b = 5;
    p = a + p;
}

int main() {
    int a = 3;
    f(a, p);
    printf("%d %d\n", p, a);
    return 0;
}

Solution