-
What is the output of this program?
#include
using namespace std;
int main()
{
int p = 15, q = 11, r = 12;
int array[3] = {&p, &q, &r};
cout << *array[*array[1] - 8];
return 0;
}
-
- 11
- 12
- 15
- Compilation Error
- Garbage value
Correct Option: D
The conversion is invalid in this array. So it will arise error. The following compilation error will be raised:
cannot convert from ‘int *’ to ‘int’
In function 'int main()':
6:35: error: invalid conversion from 'int*' to 'int' [-fpermissive]
6:35: error: invalid conversion from 'int*' to 'int' [-fpermissive]
6:35: error: invalid conversion from 'int*' to 'int' [-fpermissive]
7:9: error: 'cout' was not declared in this scope
7:32: error: invalid type argument of unary '*' (have 'int')