+ 4

What is the work of % in c++

11th Oct 2019, 4:24 PM
Hovor Eric
7 Respostas
+ 38
Correction in nAutAxH AhmAd answer He stated correctly but it's not 10 % 2 = 5 It is 10 % 2 = 0 ( As 10 is divided by 2) And 2 % 3 = 3 (incorrect) 2 % 3 = 2 ( As 2 is not divided by 3 so remainder is 2)
11th Oct 2019, 8:03 PM
Vinesh Wadhwani
Vinesh Wadhwani - avatar
+ 3
Vinesh Wadhwani🇮🇳 Thanks for correcting, didn't noticed about the typos.
12th Oct 2019, 6:05 AM
blACk sh4d0w
blACk sh4d0w - avatar
+ 2
thank you guys....
12th Oct 2019, 4:11 PM
Hovor Eric
+ 1
If two numbers are divided equally then remainder would be Zero. If two numbers are divided unequally then the remainder would be non-zero value. 5 % 2 = 1 6 % 3 = 0 10 % 3 = 1 10 % 2 = 5 If the number on the left side of modulo operator is less than the number on the right of modulo operator, then the result will be the number on left side. 2 % 3 = 3 -5 % 10 = -5
11th Oct 2019, 7:39 PM
blACk sh4d0w
blACk sh4d0w - avatar
0
please it not clear
11th Oct 2019, 5:31 PM
Hovor Eric
0
simply put , the modulo operater gives you the remainder , its division but only considering the remainder of the division executed
13th Oct 2019, 6:16 AM
Joakim Bongani Munyanyi
Joakim Bongani Munyanyi - avatar