+ 1

int main() { int i=4; int ii=i*i; int iii = ii*i; cout <<iii/ii-i<<endl ; //Outputs 0 return 0; }

Please explain the output.

3rd Jul 2017, 10:09 AM
Kushagra Agarwal
Kushagra Agarwal - avatar
3 Answers
+ 2
i=4 ii=16 iii=64 cout<<64/16-4 64/16=4 4-4=0
3rd Jul 2017, 10:13 AM
ŠœŠ³. ŠšŠ½Š°ŠæšŸŒ 
ŠœŠ³. ŠšŠ½Š°ŠæšŸŒ  - avatar
+ 2
The division is made before (iii/ii)=x and then the result of this is substracted with i (x-i). NOTE: The output is NOT iii/(ii-i) Hope you understood itāœŒ
3rd Jul 2017, 10:14 AM
Ledio Deda
Ledio Deda - avatar
0
since division has higher precedence than subtraction u'll get 0 as output
3rd Jul 2017, 11:11 AM
Sandesh
Sandesh - avatar