11. What does the 'strcpy()' function do in C++? A. Concatenates two strings B. Compares two strings C. Returns the length of a string D. Copies one string to another Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
12. What is the output of the following code: char str[] = "Hello"; cout << sizeof(str); in C++? A. 6 B. 5 C. 4 D. Compilation error Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
13. What is the correct way to initialize a string object named 'str' in C++? A. str("Hello"); B. str = new string("Hello"); C. str = "Hello"; D. string str = "Hello"; Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
14. What is the purpose of the 'strcat()' function in C++? A. Compares two strings B. Copies one string to another C. Concatenates two strings D. Returns the length of a string Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
15. What is the output of the following code: char str[] = "Hello"; cout << str; in C++? A. Compilation error B. Hello C. Undefined behavior D. None of the above Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
16. Which of the following correctly initializes a two-dimensional array named matrix in C++ with dimensions 3x3? A. int matrix[3][3] = {[1, 4, 7], [2, 5, 8], [3, 6, 9]}; B. int matrix[3][3] = {[1, 2, 3], [4, 5, 6], [7, 8, 9]}; C. int matrix[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; D. int matrix[3][3] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
17. What is the output of the following code snippet in C++? int arr[] = {1, 2, 3, 4, 5}; cout << arr[5]; A. 5 B. 0 C. Compilation error D. Undefined behavior Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
18. Which of the following correctly defines a string variable named name initialized with the value "John" in C++? A. string name = "John"; B. char name[] = "John"; C. char* name = "John"; D. string name("John"); Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
19. What is the purpose of the 'strcmp()' function in C++? A. Returns the length of a C-style string B. Copies one C-style string to another C. Concatenates two C-style strings D. Compares two C-style strings Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
20. Which of the following correctly declares an array of 10 integers in C++ and initializes all elements to zero? A. int arr[10] = {}; B. int arr[10]; for(int i = 0; i < 10; ++i) arr[i] = 0; C. int arr[10] = {0}; D. int arr[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board