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

Answer: a
Explanation: In this program, every thing is correct so the program runs perfectly and prints the 5 as output.

Join The Discussion