previous | start | next

Basic Arithmetic Operators

For integers, addition, subtraction and multiplication have the ususal meanings and division truncates the decimal part. The mod operator % computes the integer remainder

        int x = 25, y = 10;
        int ans;

        ans1 = x + y;  // ans1 is 35
        ans1 = x - y;  // ans1 is 15
        ans1 = x * y;  // ans1 is 250
        ans1 = x / y;  // ans1 is 2
        ans1 = x % y;  // ans1 is 5
     


previous | start | next