Spring 2023 Final Exam Key
- …
84 64 2e 79 06 16 17 69 FF 82 20 11 85 83 60 01 85 83 0xD6 0x07 - A:
68 02 73 45, B: 02 68 45 73 - B only
- Creates 3 output wires: a, b, c, where a is x XOR y, b is (x AND y) XOR z, and c is (x AND y) AND z.
- 16
- False, True, True, False
printf("%s", argv[2]); -
int csostrncmp(const char *s1, const char *s2, size_t n) {
size_t i = 0;
while (i < n && s1[i] && s2[i]) {
unsigned char a = (unsigned char) s1[i]; // EC
unsigned char b = (unsigned char) s2[i]; // EC
if (a < b)
return -1;
if (a > b)
return 1;
i++;
}
unsigned char a = (unsigned char) s1[i]; // EC
unsigned char b = (unsigned char) s2[i]; // EC
if (a < b)
return -1;
if (a > b)
return 1;
return 0;
}
- 21
buffer - 5, X, 15, 16, X
- A, B, and D
- D (tell the author)
- Stack, Both, Heap, Heap, Neither, Neither
Or do not. Do. There is no try. - Yoda - C and E
write(s,buf,strlen(buf));