Hi all,
I'm looking at the modulus operator and having a hard time understanding its practical purpose. The book shows me:
Code:
#include <stdio.h>
{
int a = 25, b = 5, c = 10, d = 7;
printf ("a %% b = %i\n, a % b);
printf ("a %% c = %i\n, a % c);
printf ("a %% d = %i\n", a % d);
printf ("a/d*d+a %% d = %i\n", a /d*d+a % d);
return 0;
}
While I understand what is happening here, I have a hard time invisioning other practical programming situations where this operator is useful. Can any one provide practical examples, and use common language to better explain why the modulus operator is useful?