c++ modulo make it give only positive numbers

C++
int mod(int a, int b) {
  return (a+b)%b;
}
Source

Also in C++: