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 i;
char c;
void *data;
i = 2;
c = ‘d’;
data = & i;
cout << “the data points to the integer value” << data;
data = & c;
cout << “the data now points to the character” << data;
return 0;
}

What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main()
{
int i;
char c;
void *data;
i = 2;
c = ‘d’;
data = & i;
cout << "the data points to the integer value" << data;
data = & c;
cout << "the data now points to the character" << data;
return 0;
}
a) 2d
b) two memory addresses
c) 3d
d) 4d

Answer: b
Explanation: Because the data points to the address value of the variables only, So it is printing the memory address of these two variable.
Output:
the data points to the integer value0xbfc81824 the data now points to the character0xbfc8182f

Join The Discussion