Simply use modulo
#include <stdio.h>
int main(){
for (int i = -23;i<23;i++) printf("%d %d\n",i,i%11);
return 0;
}
all modern C variants should work the same way https://en.wikipedia.org/wiki/Modulo_operation (result have same sign as divident):
-23 -1
-22 0
-21 -10
-20 -9
-19 -8
-18 -7
-17 -6
-16 -5
-15 -4
-14 -3
-13 -2
-12 -1
-11 0
-10 -10
-9 -9
-8 -8
-7 -7
-6 -6
-5 -5
-4 -4
-3 -3
-2 -2
-1 -1
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 0
12 1
13 2
14 3
15 4
16 5
17 6
18 7
19 8
20 9
21 10
22 0
for new formulation of request fixed by @Gerben suggestion
if you want monotonic 0..10 sequencies, add 11, if result is negative :
#include <stdio.h>
int main(){
for (int i = -23;i<23;i++)
{
int x= i%11 ;
x += x<0?11:0;
printf(" %d %d\n",i,x);
};
return 0;
}
results in
-23 10
-22 0
-21 1
-20 2
-19 3
-18 4
-17 5
-16 6
-15 7
-14 8
-13 9
-12 10
-11 0
-10 1
-9 2
-8 3
-7 4
-6 5
-5 6
-4 7
-3 8
-2 9
-1 10
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 0
12 1
13 2
14 3
15 4
16 5
17 6
18 7
19 8
20 9
21 10
22 0