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 &q = NULL;
cout<< q;
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 &q = NULL;
cout<< q;
return 0;
}
a) NULL
b) 0
c) Address of NULL
d) error

Answer: d
Explanation: NULL cannot be assigned to references therefore the program gives error. Here it is an int reference and NULL is not an int therefore cannot be assigned to this reference.

Join The Discussion