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>
using namespace std;
int main ()
{
int cin;
cin >> cin;
cout << “cin: ” << cin;
return 0;
}

What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main ()
{
int cin;
cin >> cin;
cout << “cin: ” << cin;
return 0;
}
a) cin: garbage value
b) Error
c) Segmentation fault
d) Nothing is printed

Answer: a
Explanation: cin is a variable hence overrides the cin object. cin >> cin has no meaning so no error

Join The Discussion