+ 18
Explain the OUTPUT ?
int main(){ int a=10,b=-3; int ans=a/b; cout<<ans<<endl; ans=a%b; cout<<ans<<endl; return 0; } OUTPUT: -3 1
3 odpowiedzi
+ 14
ROHIT KANOJIYA⚔️🇮🇳{€X∆M$}🇮🇳⚔️
In C, C++ language with a remainder operator, the sign of the result is the same as the sign of the dividend.
So
10 % 3 = 1
-10 % 3 = -1
10% -3 = 1
-10 % -3 = -1
Now, you can analyze when dividend is positive the answer will be positive else vice versa
+ 8
10/-3=-3...because the operator gives only the quotient..
Now 10%3=1 becaz the modulo operator just gives the remainder after complete division...☺
+ 2
because you used int for a and b, thats why it gives you only -3