These two operations are always a bit confused. Now we can open the dark clouds and see the sky and the sky.
For integer a and B, the modulo operation or remainder operation methods are as follows:
1. Calculate the integer quotient: c = A/B;
2. calculation mode or remainder: r = a-c * B.
# Include <iostream> using namespace STD; void Div () {printf ("5/3: % d", 5/3); cout <Endl; printf ("5/(-3): % d ", 5/-3); cout <Endl; printf (" (-3)/8: % d ",-3/5); cout <Endl; printf ("3/(-8): % d", 3/-5); cout <Endl;} void Mod () {printf ("5 modulo 3: % d ", 5% 3); cout <Endl; printf (" 5 Modulo-3: % d ", 5%-3); cout <Endl; printf ("-3 modulo 5: % d",-3% 5); cout <Endl; printf ("3 Modulo-5: % d ", 3%-5); cout <Endl;} void main () {cout <"quotient calculation" <Endl; Div (); cout <Endl; cout <"modulo operation" <Endl; Mod ();}
Calculation Result: