/*
    Integer_math2 program to illustrate some more subtle issues with division and integer math

    Given two integers  x and n<=x then x can be written  x= q*n + r 
    where q is the quotient q=x/n and r is the rest r=x%r

    See Nyhoff P67-70
*/

#include <iostream> 
using namespace std;

int main()         
{                  
   int a=10;
   int b=3;

   int fraction=a/b;                                // 10/3 = 3
   cout << "fraction" << fraction << endl;

   int modulus=a%b;                                 // 10%3 = 1    both because 10=3*3+1
   cout << "modulus=" << modulus << endl;

   int eq=(2*2+1)*4/5+1+10/4+33%10;                 // Can you calculate the result?
   cout << "eq=" << eq << endl;

   return 0;                        
}                                   
