0

Please explain the output

int a= 30; int b=6; cout << a/b--;

10th Oct 2020, 6:48 AM
Uttaran Das
Uttaran Das - avatar
4 Antworten
+ 5
B decrements to 5 after the statement has finished,if you print the result 2 times you will see this.
10th Oct 2020, 7:06 AM
D_Stark
D_Stark - avatar
+ 2
Thirteen post decrement operator is used here(not pre-decrement) so the value of *b* will be decremented after the calculation of "a/b" thus the answer should be 5 instead of 6. Here is a working sample👇 https://code.sololearn.com/cT7TwS7bMZ23/?ref=app
10th Oct 2020, 7:02 AM
Arsenic
Arsenic - avatar
+ 1
What do you think output should be, according to you ?
10th Oct 2020, 6:57 AM
Arsenic
Arsenic - avatar