Consider the following C declaration:
```c
char msg[] = "OK";
```
What is the numerical value of sizeof(msg)?
B
Step-by-Step Solution
Key idea: This is an estimation question testing the difference between the sizeof operator and the strlen function for character arrays.
Step 1: Identify the declaration. msg is a character array initialized with a string literal.
Step 2: Determine the contents. The string "OK" consists of two visible characters: 'O' and 'K'.
Step 3: Apply the string literal rule. The compiler automatically appends a null terminator (\0) to the end of the string literal.
Step 4: Calculate the total size. The array contains 'O' (1 byte), 'K' (1 byte), and '\0' (1 byte). Total = 3 bytes.
Answer: B.