C++ Programming - References - Discussion
Discussion Forum : References - Programs (Q.No. 4)
4.
Which of the following statement is correct about the program given below?
#include<iostream.h>
int main()
{
int x = 10;
int &y = x;
x = 25;
y = 50;
cout<< x << " " << --y;
return 0;
}
Discussion:
13 comments Page 2 of 2.
Aayush said:
1 decade ago
Because there is & so it will act as an alias.
&y=x means that every change in x will be the same in y.
x and y will be the same :).
&y=x means that every change in x will be the same in y.
x and y will be the same :).
Sada said:
1 decade ago
How reflected?
Aakash said:
1 decade ago
Change in y will also b reflected in x. thats why x=y=50;
Then a decrement in y therefore in x too.
And answer is 49 49.
Then a decrement in y therefore in x too.
And answer is 49 49.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers