1. [40 points] Consider the following portion of memory, displayed as a table like we have been
drawing in class. Each table cell is a memory location, which contains a single byte, with values
shown in hex, and the address of the rightmost byte on each row is shown to the right of the row.
Addresses increase as we move to the left and up in the table.
Address
00 21 6c 6f 0x77ad5f3e
6f 63 20 73 0x77ad5f3a
69 20 73 63 0x77ad5f36
20 55 59 42 0x77ad5f32
(a) [4 points] What are the contents of memory location 0x77ad5f32 in binary?
(b) [4 points] What are the contents of memory location 0x77ad5f3c in binary?
For each of the following code snippets, which include \texttt{printf} statements, write down what
would be printed out. In each part, assume that \texttt{p} is a pointer of type \texttt{void} that has the
value 0x77ad5f32.
(c) [4 points]
int a = (int *)p;
printf("%x", a);
Output:
(d) [4 points]
int a = (int *)p;
printf("%x", (a+1));
Output:
(e) [4 points]
char b = (char *)p;
printf("%c", b);
Output:
(f) [4 points]
char b = (char *)p;
printf("%c", *(b+1));
Output:
(g) [4 points]
char b = (char *)p;
printf("%c", *(b+7));
Output:
(h) [4 points]
char b = (char *)p;
printf("%s", b);
Output:
(i) [4 points]
char b = (char *)p;
printf("%s", (b+4));
Output:
(j) [4 points]
long b = (long *)p;
printf("%lx", *(b+1));
Output: