Pointers And References In C Plus Plus - Study Mode

[#91] What will be the output of the following C++ code? #include <iostream>
using namespace std
int main()
{
int a = 5, b = 10, c = 15
int *arr[ ] = {&a, &b, &c}
cout << arr[1]
return 0
}
Correct Answer

(D) it will return some random number

[#92] What will be the output of the following C++ code? #include<iostream>
using namespace std
int main()
{
int x = 10
int& ref = x
ref = 20
cout << x << endl
x = 30
cout << ref << endl
return 0
}
Correct Answer

(A) 20 30

[#93] What will be the output of the following C++ code? #include <iostream>
using namespace std
int main()
{
int a[2][4] = {3, 6, 9, 12, 15, 18, 21, 24}
cout << *(a[1] + 2) << *(*(a + 1) + 2) << 2[1[a]]
return 0
}
Correct Answer

(B) 21 21 21

[#94] What will be the output of the following C++ code? #include <iostream>
using namespace std
int main()
{
int i
const char *arr[] = {"C", "C++", "Java", "VBA"}
const char *(*ptr)[4] = &arr
cout << ++(*ptr)[2]
return 0
}
Correct Answer

(A) ava

[#95] How do you declare a pointer variable in C++?
Correct Answer

(C) type *ptr