+ 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;}
2 Respostas
+ 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.
- 2
fyffyjyfyjffjjjfyjfy