You can prepare effectively for Software Development DSA in C++ with this dedicated MCQ Practice Test (available with solutions) on the important topic of "Test: Dynamic Allocation - 2". These 15 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.
Which operator is used to dynamically allocate memory in C++?
Detailed Solution: Question 1
Detailed Solution: Question 2
Detailed Solution: Question 3
What does the keyword "inline" indicate in a function declaration?
Detailed Solution: Question 4
Which keyword is used to declare a constant variable in C++?
Detailed Solution: Question 5
What is the output of the following code?
#include <iostream>
using namespace std;
int main() {
int* ptr = new int(5);
cout << *ptr << endl;
delete ptr;
return 0;
}
Detailed Solution: Question 6
What is the output of the following code?
#include <iostream>
using namespace std;
#define SQUARE(x) x*x
int main() {
int num = 5;
cout << SQUARE(num + 1) << endl;
return 0;
}
Detailed Solution: Question 7
What is the output of the following code?
#include <iostream>
using namespace std;
int sum(int x = 2, int y = 3);
int main() {
cout << sum(5) << endl;
return 0;
}
int sum(int x, int y) {
return x + y;
}
Detailed Solution: Question 8
What is the output of the following code?
#include <iostream>
using namespace std;
static int count = 0;
int main() {
cout << count++ << endl;
count++;
cout << count << endl;
return 0;
}
Detailed Solution: Question 9
What is the output of the following code?
#include <iostream>
using namespace std;
int main() {
const int x = 5;
int* ptr = (int*)&x;
*ptr = 10;
cout << x << endl;
return 0;
}
Detailed Solution: Question 10
What is the output of the following code?
```cpp
#include <iostream>
using namespace std;
inline int multiply(int a, int b) {
return a * b;
}
int main() {
int result = multiply(2, 3) + multiply(4, 5);
cout << result << endl;
return 0;
}
```
Detailed Solution: Question 11
What is the output of the following code?
```cpp
#include <iostream>
using namespace std;
#define MAX(a, b) ((a) > (b) ? (a) : (b))
int main() {
int num1 = 10, num2 = 5, num3 = 8;
int maxNum = MAX(num1++, num2++);
cout << maxNum << endl;
return 0;
}
```
Detailed Solution: Question 12
What is the output of the following code?
```cpp
#include <iostream>
using namespace std;
const int num = 5;
void increment() {
const int num = 10;
cout << ++num << endl;
}
int main() {
increment();
cout << num << endl;
return 0;
}
```
Detailed Solution: Question 13
What is the output of the following code?
```cpp
#include <iostream>
using namespace std;
int getValue() {
static int num = 0;
num++;
return num;
}
int main() {
cout << getValue() << endl;
cout << getValue() << endl;
cout << getValue() << endl;
return 0;
}
```
Detailed Solution: Question 14
What is the output of the following code?
```cpp
#include <iostream>
using namespace std;
int main() {
const int arr[] = {1, 2, 3};
int* ptr = const_cast<int*>(arr);
*ptr = 10;
cout << arr[0] << endl;
return 0;
}
```
Detailed Solution: Question 15
152 videos|118 docs|24 tests |