#include <iostream> using namespace std; int main() { int i = 3; int l = i / -2; int k = i % -2; cout << l << k; return 0; }
a) compile time error
b) -1 1
c) 1 -1
d) implementation defined
#include <iostream> using namespace std; int main() { int i = 3; int l = i / -2; int k = i % -2; cout << l << k; return 0; }
a) compile time error
b) -1 1
c) 1 -1
d) implementation defined
You must be logged in to post a comment.
b
Explanation: Sign of result of mod operation on negative numbers is sign of the dividend.