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 = 5;
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 = 5;
cout<< q;
return 0;
}
a) 5
b) Run-time error
c) Segmentation fault
d) Compile-time error

Answer: d
Explanation: References require are other names for variables not for a constant literal. No such assignment are allowed in C++.

Join The Discussion