📝
ArkyEdu TIC
RO Solve Interactive
Grade 7 · Graded Exam (Rubric) · 35 min · 100p (10p ex officio)

Grade 7 C++ Exam with Rubric: `if/else` Branching & Logical Operators (`&&`, `||`, `!`) (100 pts)

Quick Summary & Key Points:

Covers the top Grade 7 C++ decision concepts (100 pts): `==` vs `=`, dangling semicolon after `if (...)`, writing proper range checks `(10 <= x && x <= 99)`, and tracing max-of-3.

Theory Snapshot: Never write `10 <= x <= 99` in C++ (since `(10 <= x)` yields `0` or `1`, both `<= 99`!). Always write `(10 <= x && x <= 99)`.

1. Part I · 1 (18p)

How do you CORRECTLY check in C++ that `x` is a positive 2-digit integer (between 10 and 99 inclusive)?

Answer & Explanation: B) if (x >= 10 && x <= 99) — Use `&&` (logical AND) to require both bounds. `||` would always be true, and `10 <= x <= 99` evaluates `(10 <= x)` to `0` or `1` first!

2. Part I · 2 (18p)

What does `int a = 3; if (a = 0) cout << "YES"; else cout << "NO";` print (notice single `=`)?

Answer & Explanation: B) NU / NO — `a = 0` assigns `0` to `a`, and `0` evaluates to False in C++, so the `else` branch runs and prints NO.

3. Part II · 1 (18p)

What does the C++ code below print when `x = 12` and `y = 5`?

int x = 12, y = 5;
if (x % 3 == 0 && y % 2 == 1) {
    cout << x + y;
} else {
    cout << x - y;
}

Answer & Explanation: 17 — `12 % 3 == 0` is True AND `5 % 2 == 1` is True, so it enters `if` and prints `12 + 5 = 17`.

4. Part II · 2 (18p)

True or False: Three positive sides `a, b, c` form a valid triangle if and only if `a + b > c && a + c > b && b + c > a`.

Answer & Explanation: A) True — True! By the Triangle Inequality Theorem, every pair sum must strictly exceed the third side.

5. Part III (18p)

Watch out for the classic C++ trap! What does the code below print (notice `;` right after `if`)?

int n = 4;
if (n > 10);
    cout << "Salut";

Answer & Explanation: Salut — The trailing `;` terminates `if (n > 10)` with an empty statement, so `cout << "Salut";` executes unconditionally!

Official 100-Point Grading Rubric (Grade 1–10)

Section Evaluated Competency Points
Part I (2 × 18 pts) Range conditions `&&` & assignment trap `=` inside `if` 36p
Part II (2 × 18 pts) Logical expression trace & triangle inequality 36p
Part III (18 pts) Debugging dangling semicolon `;` after `if` 18p
Ex officio Baseline points 10p
TOTAL (Grade = Score / 10) 100p

More Worksheets & Related Links