Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

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 &p;
int a = 5;
&p = a;
cout<< p;
return 0;
}

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 &p;
int a = 5;
&p = a;
cout<< p;
return 0;
}
a) 5
b) 55
c) error
d) Segmentation fault

Answer: c
Explanation: Every reference should be initialized during its declaration but as p is not initialized here therfore the program gives error.

Join The Discussion