This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Can any one please tell me how

7 mod 10 = 7

and

-2 mod 10 =8

Thanks.

7 mod 10 = 7

and

-2 mod 10 =8

Thanks.

a mnemonic to help remember them is to think of it is as a circle of values

```
7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
-3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
```

and the pattern of 0-9 loops forever in both positive and negative direction

Another way to look at this is to start with 7, and add 10 as many times as you like. Since 10 = 0 mod 10

Once you see this you can also subtract 10 as many times as you like. This can get you into negative numbers.

So 8 = 8 mod 10. And (8 -10) = -2 = 8 mod 10 and (8 -10 - 10) = -12 = 8 mod 10

Wrong. Divde 7 by 10 to get 0 and remainder 8

You have to understand the positive numbers before you tackle the negative.

27 divided by 10 ==> 2 with remainder 7. 2 * 10 + 7 = 27

7 divided by 10 ==> 0 with remainder 7. 0 * 10 + 7 = 7

7/10 is 0 with 7 left over (0*10 + 7 = 7) so 7 mod 10 is 7

16/10 is 1 with 6 left over (1*10 + 6 = 16) so 16 mod 10 is 6

-2/10 is 0 with -2 left over, but we don't want negative answers so let's fix it

-2/10 is -1 with 8 left over (-1*10 + 8 = -2) so -2 mod 10 is 8

That's how I explain the reasons.

I don't see the need for a split. http:#a36718497 basically just showed him what he already knew (the answers) not why they are the answers.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.