// Arithmetic // ---------- // Correctness // Addition, Multiplication // integers // real // mixed-mode: integers & reals // Subtraction // integers // small - large, large - small, equal // real // small - large, large - small, equal // mixed-mode: integers & reals // Division // integers // large / small, small / large, // real numbers // large / small, small / large, // mixed-mode: integers & reals // Modulus // integers // large op small, small op large, equal op equal // real - error 4 + 5 3 * 4 2.5 + 1.5 2.5 * 2.0 3 + 5.5 3.5 * 2 4 - 7 8 - 5 6 - 6 5.5 - 3.0 2.0 - 4.5 4.0 - 4.0 7 - 3.5 4 - 6.5 8 - 8.0 7 / 4 3 / 6 6.0 / 4.0 4.0 / 8.0 6.0 / 4 2.0 / 4 7 % 4 4 % 7 6 % 6 5.0 % 2 // Precedence // {Addition, Subtraction} Vs {Multiplication, Division, Modulus} 4 + 3 * 2 + 2 3 + 4 * 2 + 3 5.5 + 2 + 12 / 5 3 + 4.5 + 8 / 3 10 - 6 - 9 / 4 9 - 5 - 7 / 3 12 + 5 - 6.0 * 4 10 + 4 - 5 * 3.0 10 / 4 + 10.0 / 4.0 15.0 / 6.0 - 15 / 6 10 % 3 + 3 % 10 12 % 5 + 5 % 12 3 / 7 - 7 / 3 4 / 9 - 9 / 4 3 / 6 + 3 % 6 4 / 8 + 4 % 8 12 % 4 - 4.0 * 2.5 15 % 5 - 2.0 * 5.0 // Associativity // Subtraction // one - two - three // Division // one / two / three // Modulus // one % two % three 9 - 5 - 2 11 - 6 - 3 12 / 2 / 2 16 / 8 / 4 9 % 5 % 2 11 % 6 % 3 5 * 4 / 3 % 4 3 * 10 / 4 % 4 // ------------------------------------------------------------------------- // Precedence - Two Operators only - ALL DONE // + *, + / (both int and real), + % // - *, - / (both int and real), - % // Error for modulus # 2 Operator.Arithmetic. > 3 + 4 * 5 > Type: output Hardness: 30 4.0 + 6 * 3 6 + 7 / 3 5 + 7.0 / 4.0 4 + 4.0 / 8 3.5 + 7 / 4 3 + 7 % 4 4.0 + 3 % 8 8 - 2 * 5 7 - 1.5 * 2 7 - 4 / 3 9 - 6 / 4.0 7 - 2.0 / 8.0 8.5 - 4 / 6 9 - 4 % 6 8.5 - 8 % 3 5 + 6.0 % 6 8 + 4 % 8.0 9 - 4 % 4.0 7 - 9.0 % 2 // ------------------------------------------------------------------------- // Precedence - 3 Operators // + + * (int), + * + (real) // * + * // + + / (int), + / + (real) // / + / // + + % (int), + % + // % + % // - - * (int), - * - (real) // * - * // - - / (int), - / - (real) // / - / // - - % (int), - % - // % - % // % with errors 4 + 3 * 2 + 2 3 + 4 * 2 + 3 5.5 + 2 + 12 / 5 3 + 4.5 + 8 / 3 10 - 6 - 9 / 4 9 - 5 - 7 / 3 12 + 5 - 6.0 * 4 10 + 4 - 5 * 3.0 10 / 4 + 10.0 / 4.0 15.0 / 6.0 - 15 / 6 10 % 3 + 3 % 10 12 % 5 + 5 % 12 3 / 7 - 7 / 3 4 / 9 - 9 / 4 3 / 6 + 3 % 6 4 / 8 + 4 % 8 12 % 4 - 4.0 * 2.5 15 % 5 - 2.0 * 5.0 // ------------------------------------------------------------------------- // Associativity - 2 operators- ALL DONE // + + + // - - - // * * * // / / / // % % % 3 + 4 + 5 2 + 5 + 3.0 9 - 5 - 2.0 11 - 3.0 - 6 2 * 3 * 1.5 4 * 1.5 * 2 12 / 2 / 2 16 / 8 / 4 10 / 2.5 / 2 9 / 3 / 2.0 9 % 5 % 2 10 % 6 % 3 10 % 4 % 3.0 15 % 6.0 % 2 15.0 % 2.5 % 4 // ------------------------------------------------------------------------- // Associativity - 3 operators // + - + and - + - // * / * - both int and real // / * / - both int and real <<< CONTINUE HERE // * % * and % * % // / % / and % / % // * / %, * % /, / * %, / % *, % * /, % / * 3 + 4 - 2 + 5 2 + 5 - 3 + 6.0 9 - 5 + 7 - 4 8 - 3 + 4.0 - 6 5 * 2 / 4 * 3 3 * 3 / 5 * 1.5 2 * 5 / 4.0 * 2 3 * 4.0 / 5 * 4 / * / 4 * 3 % 5 * 2 3 * 6 % 5 * 1.5 10 / 2 % 2 / 2 12 / 2 % 4 / 4 / % / 5 * 4 / 3 % 4 3 * 10 / 4 % 4 // ------------------------------------------------------------------------- // Precedence & Associativity - more than 3 operators // // Precedence & Associativity // // Relational // ---------- // Correctness // LessThan, GreaterThan // small op large, large op small, equal op equal // LessEquals, GreaterEquals // small op large, large op small, equal op equal // Equals, NotEquals // integers, reals // small op large, large op small, equal op equal // integers, boolean // small op large, large op small, equal op equal // // Precedence // {LessThan, GreaterThan, LessEquals, GreaterEquals} Vs {Equals, NotEquals} // // Associativity // LessThan, GreaterThan // small op medium op large, large op medium op small, // small op large op medium, medium op large op small, // large op small op medium, medium op small op large, // equal op equal op equal, equal op equal op true/false // LessEquals, GreaterEquals // small op medium op large, large op medium op small, // small op large op medium, medium op large op small, // large op small op medium, medium op small op large, // equal op equal op equal, equal op equal op true/false // Equals, NotEquals // small op medium op large, large op medium op small, // small op large op medium, medium op large op small, // large op small op medium, medium op small op large, // equal op equal op equal, equal op equal op true/false // Precedence & Associativity 3 < 7 9 < 4 4 < 4 3 > 7 9 > 4 4 > 4 3 <= 7 9 <= 4 4 <= 4 3 >= 7 9 >= 4 4 >= 4 3 == 7 9 == 4 4 == 4 3 != 7 9 != 4 4 != 4 3 >= 4 == 4 >= 0 5 >= 7 == 7 >= 0 3 < 7 != 7 < 3 4 < 9 != 9 < 4 9 < 5 < 3 8 < 6 < 4 9 < 3 < 5 8 < 4 < 6 9 > 5 > 3 8 > 6 > 4 9 <= 5 <= 0 7 <= 4 <= 0 4 <= 4 <= 1 7 >= 7 >= 1 9 >= 5 >= 3 8 >= 6 >= 2 4 >= 4 >= 4 7 >= 7 >= 7 9 == 3 == 0 7 == 4 == 0 4 == 4 == 1 5 == 5 == 1 3 != 9 != 1 7 != 4 != 1 4 != 4 != 4 7 != 7 != 7 2 == 3 == 4 == 5 3 == 7 == 5 == 9 1 != 3 != 5 != 7 2 != 4 != 6 != 8 // Arithmetic & Relational // ----------------------- {+, -, *, /, %} X {<, <=, >, >=} {+, -, *, /, %} X {==. !=} 10 / 4 < 10 / 4.0 // Boolean // ------- // Arithmetic & Boolean // // Relational & Boolean // // Arithmetic, Relational & Boolean