Exercise: References
Questions for: References
What will be the output of the following program?
#include<iostream.h>
class BixTest
{
public:
BixTest(int &x, int &y)
{
x++;
y++;
}
};
int main()
{
int a = 10, b = 20;
BixTest objBT(a, b);
cout<< a << " " << b;
return 0;
}
A:
10 20
B:
11 21
C:
Garbage Garbage
D:
It will result in a compile time error.
Answer: B
No answer description is available. Let's discuss.
Which of the following statement is correct about the program given below?
#include<iostream.h>
int main()
{
int m = 2, n = 6;
int &x = m++;
int &y = n++;
m = x++;
x = m++;
n = y++;
y = n++;
cout<< m << " " << n;
return 0;
}
A:
The program will print output 3 7.
B:
The program will print output 4 8.
C:
The program will print output 5 9.
D:
The program will print output 6 10.
Answer: E
No answer description is available. Let's discuss.
Discuss About this Question.
Which of the following statement is correct about the program given below?
#include<iostream.h>
int main()
{
int m = 2, n = 6;
int &x = m;
int &y = n;
m = x++;
x = m++;
n = y++;
y = n++;
cout<< m << " " << n;
return 0;
}
A:
The program will print output 2 6.
B:
The program will print output 3 7.
C:
The program will print output 4 8.
D:
The program will print output 5 9.
Answer: C
No answer description is available. Let's discuss.
Discuss About this Question.
Which of the following statement is correct about the program given below?
#include<iostream.h>
int main()
{
int x = 0;
int &y = x; y = 5;
while(x <= 5)
{
cout<< y++ << " ";
x++;
}
cout<< x;
return 0;
}
A:
The program will print the output 5 6 7 8 9 10.
B:
The program will print the output 5 6 7 8 9 10 7.
C:
The program will print the output 5 7.
D:
It will result in a compile time error.
Answer: C
No answer description is available. Let's discuss.
Discuss About this Question.
Which of the following statement is correct about the program given below?
#include<iostream.h>
int main()
{
int x = 10, y = 20;
int *ptr = &x;
int &ref = y;
*ptr++;
ref++;
cout<< x << " " << y;
return 0;
}
A:
The program will print the output 10 20.
B:
The program will print the output 10 21.
C:
The program will print the output 11 20.
D:
The program will print the output 11 21.
Answer: B
No answer description is available. Let's discuss.
Discuss About this Question.
Ad Slot (Above Pagination)
Discuss About this Question.