9 mod 10 gives 9, but why?

9 / 10 = 0, so the remainder should also be zero shouldn't it?

This works the same for 0-9, but why?

This is a discussion on *Why is 9 % 10 = 9?* within the **C Programming** forums, part of the General Programming Boards category; 9 mod 10 gives 9, but why?
9 / 10 = 0, so the remainder should also be zero shouldn't ...

- 05-24-2011 #1

- Join Date
- Dec 2009
- Posts
- 23

## Why is 9 % 10 = 9?

9 mod 10 gives 9, but why?

9 / 10 = 0, so the remainder should also be zero shouldn't it?

This works the same for 0-9, but why?

- 05-24-2011 #2

- Join Date
- Aug 2010
- Location
- Ontario Canada
- Posts
- 9,547

Because 10 doesn't go into 9 ... giving you 0 with a remainder of 9.

- 05-24-2011 #3Code:
divident = divisor*quotent +

**remainer**<==>**remainer**= divident - divisor*quotentDevoted my life to programming...

- Exactly how to get started with C++ (or C) today
- C Tutorial
- C++ Tutorial
- 5 ways you can learn to program faster
- The 5 Most Common Problems New Programmers Face
- How to set up a compiler
- 8 Common programming Mistakes
- What is C++11?
- Creating a game, from start to finish

- How to create a shared library on Linux with GCC - December 30, 2011
- Enum classes and nullptr in C++11 - November 27, 2011
- Learn about The Hash Table - November 20, 2011
- Rvalue References and Move Semantics in C++11 - November 13, 2011
- C and C++ for Java Programmers - November 5, 2011
- A Gentle Introduction to C++ IO Streams - October 10, 2011