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
Related Posts
What is the other name of the macro?
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
#define MAX 10
int main()
{
int num;
num = ++MAX;
cout << num;
return 0;
}What will be the output of the following C++ code?
#include <iostream>
using namespace std;
#define PR(id) cout << “The value of ” #id ” is “<< id
int main()
{
int i = 10;
PR(i);
return 0;
}What will be the output of the following C++ code?
#include <iostream>
using namespace std;
#define SquareOf(x) x * x
int main()
{
int x;
cout << SquareOf(x + 4);
return 0;
}What is the mandatory preprocessor directive for c++?
How many types of macros are there in c++?
Which symbol is used to declare the preprocessor directives?
Join The Discussion