# Tests
[toc]
## MULTIPLE CHOICE:
1. Which of the following is a correct way to writh the value 0xAA55 to physical memory address 0x67A9?
(1) uint16_t * p = (uint16_t*) 0x67A9; p = 0xAA55;
(2) uint16_t * p = (uint16_t*) 0xAA55; p = 0x67A9;
(3) * (unit16_t * const) (0x67A9) = 0xAA55;
(4) * (unit16_t * const) (0xAA55) = 0x67A9;
2. Which of the following code snippets can be used to reset the least-significant bit of x?
(1) x & 0x01;
(2) x & ~0x01;
(3) x | ~0x01;
(4) x &= ~ 0x01;
3. Which of the following statements accurately describes the meaning of the declaration int * const x;?
(1) #define MIN(A, B) ( (A) < (B) ? (A) : (B))
(2) #define MIN(A, B) { if (A < B) A; else B; }
(3) #define MIN(A, B) ( (A) < (B) ? A : B)
(4) #define MIN(A, B) A < B ? A : B;
4. Which of the following satements accurately describes the intended effect of the declaration int {*a) [10]; ?
(1) An array of ten ingegers
(2) A pointer to an array of ten integers
(3) An array of ten pointers to integers
(4) An array of ten pointers to functions
## SIMPLE QUESTIONS
1. What are 3 distinct functions of L2 switching?
2. What is TCP 3-way handshake?
3. List HTTP methods that you know.
4. What is ICMP?
5. What is default route, static route?
6. What is the difference between TCP and UDP?
7. What is the difference between ARP and RARP?
8. What is Proxy ARP?
9. What are the major components of a toolchain?
10. Illustrate hard link and soft link in Linux system.
11. What is a zombie process?
12. Describe difference between malloc, realloc and calloc.
13. How is a library call different from a system call?
14. Draw a source control example of history graph thatincludes tags, branches, merges, trunks, and discontinued development branch.
15. Describe what is heap and stack, give some examples that allocate memory in heap and stack in C.
16. What is int *p[10] and int (*p)[10]? Give an example about how to use it.
17. Assume there is a function int* clone_string(const char* string, int str_len), write a function pointer that points to it.
## PROGRAMMING QUESTIONS:
Please write down your answer in spared sheet.
1. What is the output of following "C" code (assume 32bits Linux machine)?
```C
int main(void)
{
struct{
char x1:2;
char x2:2;
char x3:2;
}a;
struct{
char x1:6;
char x2:5;
char x3:4;
}b;
printf("size of a=%d\n",sizeof(a));
printf("size of b=%d\n",sizeof(b));
return 0;
}
```
2. What is the output of the code below?
```C
#include <stdio.h>
#include <stdlib.h>
int print_me(void) {
static int a ==1;
printf("%d\n",++a);
return 0;
}
int main(void) {
int i;
for (i=0;i<3; i++) {
print_me();
}
return 0;
}
```
3. Write a shell script that reversed a string, for example:
```
Input : "abcdefg"
Output: "gfedcba"
```
4. Same question as "3" , but writh it in C code.
```
Input : "abcdefg"
Output: "gfedcba"
```
5. Write a C cdoe that reversed a sentence, for example:
```
Input : "This is a book."
Output: "book a is This."
```
Please note, sentence means a string that ends at a dot".".