+ 1

When we use modulus in c++

2nd Mar 2017, 3:54 AM
Satyam Jaiswal
Satyam Jaiswal - avatar
2 Antworten
+ 2
a good example of the use of modulus is to find all the even numbers in a loop. remember modulus returns the remainder not the division. e.g. 5%2=1
2nd Mar 2017, 5:57 AM
Andre van Rensburg
Andre van Rensburg - avatar
+ 2
Modulus returns the remainder of an integer. For example 5%3==2. There is also fmod() for floating point numbers.
2nd Mar 2017, 7:33 AM
Teo
Teo - avatar