- 1
Please can someone help me explain this code with the output as follows...
int x=5,y=5; cout<<x<<" "<<y<<endl; cout<<++x<<" "<<--y<<endl;// prefix cout<<x<<" "<<y<<endl; cout<<x++<<" "<<y--<<endl;// postfix cout<<x<<" "<<y<<endl; output5 56 46 46 47 3
4 Réponses
+ 6
cout<<x<<" "<<y<<endl; //prints 5 5
cout<<++x<<" "<<--y<<endl; // adds 1 to x and sub 1from y prints 6 4
cout<<x<<" "<<y<<endl; // displays the latest updated values of x and y prints 6 4
cout<<x++<<" "<<y--<<endl; // first displays the current value and then updates values of x and y
// prints 6 4 which were the current values
// adds 1 to x and sub 1 from y after displaying
// current values i.e 6 4
cout<<x<<" "<<y<<endl; // prints 7 and 3 which were updated in the previous line after printing 6 and 4
/* Hope this helps :) */
comments are a little off ... hard for me to edit from my mobile phone
0
thank you. it's very helpful.
0
There is a rule that expalin that a variable can not be upadated twice in an expression. if such things happen the result depends upon the implementation of that specific compiler .
0
Please this program is not is not working