You can prepare effectively for Software Development Basics of C++ with this dedicated MCQ Practice Test (available with solutions) on the important topic of "Test: Arrays - 1". These 20 questions have been designed by the experts with the latest curriculum of Software Development 2026, to help you master the concept.
Test Highlights:
Sign up on EduRev for free to attempt this test and track your preparation progress.
Detailed Solution: Question 1
What is the index of the first element in an array with N elements?
Detailed Solution: Question 2
Which of the following statements is true about passing arrays to functions in C++?
Detailed Solution: Question 3
Which of the following is the correct syntax to declare a 1D array of integers in C++?
Detailed Solution: Question 4
What is the time complexity of searching an element in an array using binary search (iterative method)?
Detailed Solution: Question 5
Which of the following is the correct formula to calculate the middle index in binary search?
Detailed Solution: Question 6
Binary search can be applied on which of the following types of arrays?
Detailed Solution: Question 7
Detailed Solution: Question 8
Detailed Solution: Question 9
What is the index range of elements in an array with 10 elements?
Detailed Solution: Question 10
What is the output of the following code snippet?
#include <iostream>
using namespace std;
int main() {
int arr[] = {1, 2, 3, 4, 5};
cout << arr[2];
return 0;
}
Detailed Solution: Question 11
What is the output of the following code snippet?
#include <iostream>
using namespace std;
int main() {
int arr[5] = {1, 2, 3, 4, 5};
cout << arr[5];
return 0;
}
Detailed Solution: Question 12
What is the output of the following code snippet?
#include <iostream>
using namespace std;
void modifyArray(int arr[]) {
arr[0] = 100;
}
int main() {
int arr[] = {1, 2, 3, 4, 5};
modifyArray(arr);
cout << arr[0];
return 0;
}
Detailed Solution: Question 13
What is the output of the following code snippet?
#include <iostream>
using namespace std;
void printArray(int arr[], int size) {
for (int i = 0; i < size; i++) {
cout << arr[i] << " ";
}
}
int main() {
int arr[] = {1, 2, 3, 4, 5};
printArray(arr, 5);
return 0;
}
Detailed Solution: Question 14
What is the output of the following code snippet?
#include <iostream>
using namespace std;
int binarySearch(int arr[], int left, int right, int key) {
if (left <= right) {
int mid = left + (right - left) / 2;
if (arr[mid] == key)
return mid;
if (arr[mid] > key)
return binarySearch(arr, left, mid - 1, key);
return binarySearch(arr, mid + 1, right, key);
}
return -1;
}
int main() {
int arr[] = {2, 4, 6, 8, 10};
int key = 8;
int result = binarySearch(arr, 0, 4, key);
cout << result;
return 0;
}
Detailed Solution: Question 15
What does the following code snippet do?
#include <iostream>
using namespace std;
int binarySearch(int arr[], int n, int key) {
int low = 0, high = n - 1;
while (low <= high) {
int mid = low + (high - low) / 2;
if (arr[mid] == key)
return mid;
if (arr[mid] < key)
low = mid + 1;
else
high = mid - 1;
}
return -1;
}
int main() {
int arr[] = {2, 4, 6, 8, 10};
int key = 6;
int result = binarySearch(arr, 5, key);
cout << result;
return 0;
}
Detailed Solution: Question 16
What does the following code snippet do?
#include <iostream>
using namespace std;
int binarySearch(int arr[], int low, int high, int key) {
if (low <= high) {
int mid = low + (high - low) / 2;
if (arr[mid] == key)
return mid;
if (arr[mid] > key)
return binarySearch(arr, low, mid - 1, key);
return binarySearch(arr, mid + 1, high, key);
}
return -1;
}
int main() {
int arr[] = {2, 4, 6, 8, 10};
int key = 8;
int result = binarySearch(arr, 0, 4, key);
cout << result;
return 0;
}
Detailed Solution: Question 17
What does the following code snippet do?
#include <iostream>
using namespace std;
int binarySearch(int arr[], int n, int key) {
int low = 0, high = n - 1;
while (low <= high) {
int mid = low + (high - low) / 2;
if (arr[mid] == key)
return mid;
if (arr[mid] > key)
high = mid - 1;
else
low = mid + 1;
}
return -1;
}
int main() {
int arr[] = {2, 4, 6, 8, 10};
int key = 6;
int result = binarySearch(arr, 5, key);
cout << result;
return 0;
}
Detailed Solution: Question 18
What does the following code snippet do?
#include <iostream>
using namespace std;
int binarySearch(int arr[], int low, int high, int key) {
if (low <= high) {
int mid = low + (high - low) / 2;
if (arr[mid] == key)
return mid;
if (arr[mid] < key)
low = mid + 1;
else
high = mid - 1;
return binarySearch(arr, low, high, key);
}
return -1;
}
int main() {
int arr[] = {2, 4, 6, 8, 10};
int key = 8;
int result = binarySearch(arr, 0, 4, key);
cout << result;
return 0;
}
Detailed Solution: Question 19
What does the following code snippet do?
#include <iostream>
using namespace std;
int binarySearch(int arr[], int left, int right, int key) {
if (left <= right) {
int mid = left + (right - left) / 2;
if (arr[mid] == key)
return mid;
if (arr[mid] > key)
return binarySearch(arr, left, mid - 1, key);
return binarySearch(arr, mid + 1, right, key);
}
return -1;
}
int main() {
int arr[] = {2, 4, 6, 8, 10};
int key = 12;
int result = binarySearch(arr, 0, 4, key);
cout << result;
return 0;
}
Detailed Solution: Question 20
69 videos|52 docs|15 tests |