Mod Function

//This program will demonstrate the mod function

#include<iostream.h>//nessesary for cin and cout

main()
{
int k, j;
k = 5 / 2; // integer division
j = 5 % 2; // modulus division
cout << k << "***" << j << '\n';

cout << "7%2 = " << 7%2 << '\n';
cout << "-7%2 = " << -7%2 << '\n';
cout << "7%-2 = " << 7%-2 << '\n';
cout << "-7%-2 = " << -7%-2 << '\n';
k = (k + 15) % 3 / 2;
cout << k << '\n';
cout << 2/3 << '\n';

return 0;
}

/*
2***1
7%2 = 1
-7%2 = -1
7%-2 = 1
-7%-2 = -1
1
0
*/