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 *p;
void *vp;
if (vp == p);
cout << “equal”;
return 0;
}

What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main()
{
int *p;
void *vp;
if (vp == p);
cout << "equal";
return 0;
}
a) equal
b) no output
c) compile error
d) runtime error

Answer: a
Explanation: The void pointer is easily converted to any other type of pointer, so these are equal.
Output:
equal

Join The Discussion