0
What will be the output of the code?
int x = 5; cout << ++x + x +x-x; // I know the answer, but I don’t understand why the answer is this.
5 Respuestas
+ 2
++x means increment x by 1 then use its value. So, x = 6
6 + 6 + 6 - 6 = 12
+ 2
Tahiti🍷
Short description; it is a program or collection of tools that takes your written readable code and converts it into runnable machine code, usually in the form of an executable file (exe on Windows).
https://en.m.wikipedia.org/wiki/Compiler
https://www.stroustrup.com/compilers.html
0
ChaoticDawg ,
Thank you. I thought that only the first integer/variable in the equation would be incremented. Now it makes sense.
0
Tahiti🍷
It will increment the value of the variable itself in memory.
Note: The the precedence of the increment/decrement operator(s) to the addition/subtraction operator(s) may vary from one C++ compiler to next so the answer may also vary.
0
Ok, ChaoticDawg . Now, could you explain what is a compiler? Thanks.