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: Pointers - 2". These 30 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
Which of the following is the correct way to declare a pointer variable in C++?
Detailed Solution: Question 2
What is the output of the following code snippet?
int x = 5;
int* ptr = &x;
cout << *ptr;
Detailed Solution: Question 3
Detailed Solution: Question 4
Which operator is used to access the value pointed to by a pointer in C++?
Detailed Solution: Question 5
Detailed Solution: Question 6
What is the output of the following code snippet?
int arr[] = {1, 2, 3, 4, 5};
int* ptr = arr;
cout << *(ptr + 2);
Detailed Solution: Question 7
Which of the following is true about pointer arithmetic in C++?
Detailed Solution: Question 8
Detailed Solution: Question 9
What is the purpose of the 'const' keyword when used with a pointer in C++?
Detailed Solution: Question 10
What is the output of the following code snippet?
int x = 5;
int* ptr = &x;
*ptr = 10;
cout << x;
Detailed Solution: Question 11
What is the output of the following code snippet?
int arr[] = {1, 2, 3, 4, 5};
int* ptr = arr;
cout << *ptr++;
Detailed Solution: Question 12
What is the output of the following code snippet?
int arr[] = {1, 2, 3, 4, 5};
int* ptr = arr + 2;
cout << *ptr;
Detailed Solution: Question 13
What is the output of the following code snippet?
int arr[] = {1, 2, 3, 4, 5};
int* ptr = arr;
cout << *(ptr + 3);
Detailed Solution: Question 14
What is the output of the following code snippet?
int arr[] = {1, 2, 3, 4, 5};
int* ptr = arr;
cout << ptr[2];
Detailed Solution: Question 15
What is the output of the following code snippet?
int x = 5;
int* ptr1 = &x;
int* ptr2 = ptr1;
*ptr2 = 10;
cout << *ptr1;
Detailed Solution: Question 16
What is the output of the following code snippet?
int x = 5;
int* ptr = &x;
int** ptr2 = &ptr;
cout << **ptr2;
Detailed Solution: Question 17
What is the output of the following code snippet?
int x = 5;
int* ptr1 = &x;
int* ptr2 = nullptr;
ptr2 = ptr1;
*ptr2 = 10;
cout << *ptr1;
Detailed Solution: Question 18
What is the output of the following code snippet?
int arr[] = {1, 2, 3, 4, 5};
int* ptr1 = arr;
int* ptr2 = ptr1 + 3;
cout << ptr2 - ptr1;
Detailed Solution: Question 19
What is the output of the following code snippet?
int arr[] = {1, 2, 3, 4, 5};
int* ptr = arr + 4;
cout << *(ptr - 2);
Detailed Solution: Question 20
What is the output of the following code snippet?
int* ptr = new int[5];
ptr[2] = 10;
cout << ptr[2];
delete[] ptr;
Detailed Solution: Question 21
Detailed Solution: Question 22
What is the output of the following code snippet?
int** ptr = new int*[3];
for (int i = 0; i < 3; i++) {
ptr[i] = new int[2];
for (int j = 0; j < 2; j++) {
ptr[i][j] = i + j;
}
}
cout << ptr[2][1];
for (int i = 0; i < 3; i++) {
delete[] ptr[i];
}
delete[] ptr;
Detailed Solution: Question 23
Detailed Solution: Question 24
What is the output of the following code snippet?
void print(int* arr, int size) {
for (int i = 0; i < size; i++) {
cout << arr[i] << " ";
}
}
int main() {
int arr[] = {1, 2, 3, 4, 5};
int* ptr = arr;
print(ptr, 5);
return 0;
}
Detailed Solution: Question 25
Detailed Solution: Question 26
Detailed Solution: Question 27
What is the output of the following code snippet?
#include <memory>
int main() {
std::unique_ptr<int> ptr(new int(5));
std::cout << *ptr;
return 0;
}
Detailed Solution: Question 28
Detailed Solution: Question 29
Detailed Solution: Question 30
69 videos|52 docs|15 tests |