+ 2

What is the output of this C++ code?

int a=5, b=-2, c=2; b=--b+++a%4*c++*2; cout<<b;

1st Aug 2019, 4:11 PM
Janna Al-Ward
Janna Al-Ward - avatar
8 Answers
+ 3
Dr. Doggo [D#] it's right with the compiler but I don't understand how does the output be 5.
1st Aug 2019, 4:23 PM
Janna Al-Ward
Janna Al-Ward - avatar
+ 2
Dr. Doggo [D#] and if I correct it to: b= --b+ ++a ?
1st Aug 2019, 4:18 PM
Janna Al-Ward
Janna Al-Ward - avatar
1st Aug 2019, 4:32 PM
Janna Al-Ward
Janna Al-Ward - avatar
+ 2
Martin Taylor, The last paragraph of your comment is exact. This code was a question from some exam in my university. Our teachers like to make us confuse with the hard exams, so we can try to take decisions quickly in our future job when we are confusing. This is a type of simple obstacles for us as students, and this method of teaching makes the teachers sure for us to be successful with every obstacle we find in our job in the future.
1st Aug 2019, 11:19 PM
Janna Al-Ward
Janna Al-Ward - avatar