0
can someone explain the output
hey guy I just started learning C++ and I can't explain why the output is -61 can someone explain and thank you #include <iostream> using namespace std; int main() { int x=-13.5 , y=-7; if (x*-2 != 27) cout <<x%y; cout <<x/y; return 0; }
2 Answers
+ 1
1.In the first line you declared x=-13.5 .Here x becomes 13 not 14 or 13.5 as you declared x as int.
2.So now x*-2 =26 so the condition becomes true and print x%y which is -13%-7
you can write this like that: -13-(-7)=-13+7=-6.
so it prints -6 first.
3. Now the condition breaks and now it prints x/y means -13/-7 which is 1 .
So in total it prints -61.



