Question
Consider the following C code: #include
#include int main() {   char str1[] = "Hello";   char str2[] = {'W', 'o', 'r', 'l', 'd', '\0', 'X'};   char str3[] = {'C', 'o', 'd', 'e'}; // No null terminator   printf("%zu %zu\n", strlen(str1), strlen(str2));   // What happens if strlen(str3) is called?   // printf("%zu\n", strlen(str3));   return 0; } What will be the output of the printf statement, and what would be the behavior if strlen(str3) were uncommented and executed?Solution
Correct Answer: B (strlen(str1) is 5. strlen(str2) counts up to the first \0, so 5. strlen(str3) would read past the allocated memory until it finds a \0, leading to undefined behavior (segmentation fault or garbage value).)
Which of the following is not an example of Utility Software?Â
Which of the following is not an input device ?
What is the name of the device that is used to send and receive data over a computer network?Â
Which of the following MS-Excel 2019 features helps us to add the contents of a cluster of adjacent cells?
Which of the following statement(s) is/are TRUE ?
S1 : The decimal number 11 is larger than the hexadecimal number 11.
S2 : In the binary ...
What is the primary advantage of using a stylus with a touchscreen device?
Which type of device allows the user to add components and capabilities to a computer system? Â
Which shortcut key is used for Undo?
Which of the following looks like an upside-down mouse that requires the ball to be rotated manually with a finger for moving the cursor on the computer...
Name the device which is used for directing and dispatching data packets between various networks.