How to make modulus operation in C language?
Please read my code below.
#include <stdio.h>
int main(void)
{
int i = 100;
printf("%d\n", i%100);
printf("%d\n", i%240);
printf("%d\n", i%40);
printf("%d\n", i%10);
return 0;
}
The result is
$ ./modulus
0
100
20
0
Please tell me how to use it correctly.
EDIT
Sorry I did a mistake in code. the division should come otherside like in below code.
printf("%d\n", 100%i);
printf("%d\n", 240%i);
printf("%d\n", 40%i);
printf("%d\n", 10%i);
What I was expecting was to get the 0
when the value is multiplication of 100;
I am sorry for the mistake. But guys, please undo my downvotes.