0

can someone explain why output is 5. and not 6 ?

#include <iostream> #include <string> using namespace std; int main() { int a=5; int b=1<--a;// 1 int c=1+--a;// 5 int d=1+b*c; // Output 5 cout<<d; return 0; }

3rd Apr 2019, 9:20 AM
San Anemos
San Anemos - avatar
2 Respuestas
+ 7
int c = 1 + --a; The value of `a` before this line was 4. On reaching this line it become 3, so 1 + 3 = 4. That is why value of `c` is 4 not 5. This itself further explains your question.
3rd Apr 2019, 9:34 AM
Letsintegreat
Letsintegreat - avatar
0
Thanks 👍
3rd Apr 2019, 10:00 AM
San Anemos
San Anemos - avatar