+ 1

Can someone explain the output?

#include <iostream>using namespace std;int main() {int x=0;int &y=x;y=5;while(x<=5){ cout<<y++<<""; x++;}cout<<x; return 0;}

4th Sep 2016, 3:04 PM
surya
surya - avatar
2 odpowiedzi
+ 1
Should be 57 if I'm not missing something. This is because x is a variable and y is a reference to the x. variable and as such, works as an alias to it. So y (which is x) is set to five, the 'while' runs, couts the y (again, x) and post-increments. Twice. Then simply couts again.
4th Sep 2016, 7:52 PM
Norbivar
Norbivar - avatar
- 2
fyffyjyfyjffjjjfyjfy
4th Sep 2016, 3:58 PM
R.Sai harshit
R.Sai harshit - avatar