What will be the output of the following C++ code?
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
int main(int argc, char const *argv[])
{
int a = 5;
int &q = a;
cout<<&a << endl;
cout<<&q << endl;
return 0;
}
a) 5
5
b) Address of p followed by 5 in next line
c) 5 followed by Address of a in next line
d) Address of a followed by Address of a in next line
Answer: d
Explanation: Both variable and reference shares the same addres so the output will be two times the address of a, because references are other name for same variable not a new variable with separate memory.
Related Posts
People overcome natural language problems by _____________
The integrated circuit was invented by Jack Kilby of _____________
Research scientists all over the world are taking steps towards building computers with circuits patterned after the complex interconnections existing among the human brain’s nerve cells. What name is given to such type of computers?
Which type of actuator generates a good deal of power but tends to be messy?
In LISP, the function evaluates both and is _____________
Which of the following have people traditionally done better than computers?
A bidirectional feedback loop links computer modeling with _____________
Join The Discussion