%

I would like to know what happends when using % as an operator if the first operand is lower than the second one.
In the followtin code, I don't get how n is calculated...
Thanks a lot

1
2
3
4
5
6
 #include <stdio.h>
int main() {
  int i=0;
  int n;
  n=(i+2)%3;
  printf("d%",n);
1
2
3 % 10
= 0 * 10 + 3

Therefore, 3 % 10 = 3.
Topic archived. No new replies allowed.