1. What is the correct way to declare a one-dimensional array in C++? A. int* arr = new int[size]; B. int[] arr = new int[size]; C. int arr = new int[size]; D. int arr[size]; 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
2. How do you access the third element of an array named 'arr' in C++? A. arr(3) B. arr[3] C. arr[2] D. arr(2) 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
3. What is the size of the following array declaration in C++: char str[10];? A. 11 B. 10 C. Depends on the length of the string assigned to 'str' D. None of these 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
4. What is the purpose of the 'strlen()' function in C++? A. Concatenates two strings B. Compares two strings C. Returns the length of a null-terminated string D. Copies a string to another 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
5. How do you initialize all elements of an integer array named 'arr' to zero in C++? A. arr[] = {0}; B. arr = {0}; C. arr.fill(0); D. for (int i = 0; i < size; ++i) { arr[i] = 0; } 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
6. What is the correct syntax for declaring a two-dimensional array in C++? A. int arr[rowSize][colSize]; B. int arr = new int[rowSize][colSize]; C. int[] arr[rowSize][colSize]; D. int* arr[rowSize][colSize]; 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
7. Which of the following statements is true about C-style strings in C++? A. They must be declared using the 'string' keyword B. They are objects of the 'string' class C. They can have variable lengths D. They are represented as arrays of characters terminated by a null character 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
8. What is the output of the following code: char str[] = "Hello"; cout << str[5]; in C++? A. H B. o C. Undefined behavior D. Compilation error 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
9. How do you determine the length of a C-style string in C++? A. Subtracting the address of the first character from the last B. Using the 'strlen()' function C. Counting the number of elements in the array 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
10. What is the correct way to pass an array as an argument to a function in C++? A. By declaring the array as global B. By passing the array itself C. Using a pointer to the array D. By passing each element of the array individually 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