Spring 2023 Final Exam Key

  1. 84 64 2e 79 06 16 17 69 FF 82 20 11 85 83 60 01 85 83
  2. 0xD6
  3. 0x07
  4. A: 68 02 73 45, B: 02 68 45 73
  5. B only
  6. 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.
  7. 16
  8. False, True, True, False
  9. printf("%s", argv[2]);
  10. 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;
    }
    
  11. 21
  12. buffer
  13. 5, X, 15, 16, X
  14. A, B, and D
  15. D (tell the author)
  16. Stack, Both, Heap, Heap, Neither, Neither
  17. Or do not. Do. There is no try. - Yoda
  18. C and E
  19. write(s,buf,strlen(buf));

Copyright © 2025 John Hott, portions Luther Tychonievich.
Released under the CC-BY-NC-SA 4.0 license.
Creative Commons License