← Back to Question List
C++ Code Walkthrough #42
Modulo and Division With Negative Numbers
📄 Code
Read carefully — what does this print?1#include <iostream>2using namespace std;34int main() {5 cout << -7 / 2 << " " << -7 % 2 << endl;6 cout << 7 / -2 << " " << 7 % -2 << endl;7 cout << (-7 / 2) * 2 + (-7 % 2) << endl;8 return 0;9}