+ 1

I want to ask that in c++ compiler why cout<<2*3+9 ; & cout<<2*3+9-1/2 ; giving me the same output "15" ??

C++ Question

28th Mar 2019, 4:55 PM
Sandeep Garai
Sandeep Garai - avatar
2 Respostas
+ 7
Hi Sandeep, I think this probably be how the expression was evaluated: 2*3+9-1/2 ; (2*3)+9-(1/2) // <- integer division 1/2 yields zero (2*3)+9-(0) Output: 15 Hth, cmiiw
28th Mar 2019, 5:04 PM
Ipang
+ 2
Oh yes .. got It . Thanks for helping me though 🙃
29th Mar 2019, 5:36 AM
Sandeep Garai
Sandeep Garai - avatar