+ 2
Explain the output of the code?
#include <iostream> using namespace std; int main () { int x, y; x = 5; y = ++x * ++x; cout << x << y; x = 5; y = x++ * ++x; cout << x << y; return 0; }
1 Respuesta
+ 5
IN PREFIX ++x FIRST x IS INCREMENTED AND THAN EVALUATION TAKE PLACE.
IN POSTFIX x++ FIRST EVALUATION IS DONE AND THAN ITS VALUE IS INCREMENTED.
Decrement goes same way.
Small example
x = x + x++ + ++x + x
=4
+ 4(post increment now x=5)
+ 6(pre increment)
+ 6.
=20.
Hope this will help you understand your code☺️☺️.