Correct option is A
The algorithm reads num and checks remainder(num / 2) == 0.
If a number leaves zero remainder when divided by 2, it is even by definition.
Upon true, it displays "yes"; otherwise "no" for odd numbers.
This logic does not test for primality or Armstrong property.
Hence, an output of "yes" means num is even.
Upon true, it displays "yes"; otherwise "no" for odd numbers.
This logic does not test for primality or Armstrong property.
Hence, an output of "yes" means num is even.
Important Key Points
- Even test: num % 2 == 0 ⇔ even; num % 2 == 1 (or != 0) ⇔ odd (for nonnegative integers).
- Negative numbers: Even/odd parity still holds: e.g., -4 % 2 == 0 → even.
- No primality check: Primality requires divisibility tests beyond 2; not done here.
- No Armstrong check: Armstrong (narcissistic) numbers involve sum of powered digits; unrelated.
- I/O flow: Prompt → read → parity check → print "yes"/"no".
- Edge case: num = 0 is even since 0 % 2 == 0.
Knowledge Booster
- Why not (b) Armstrong? Needs digit-power sum equality (e.g., 153); modulus by 2 says nothing about that.
- Why not (c) Odd? Odd numbers give remainder 1 (or -1), producing "no".
- Why not (d) Prime? Many even numbers aren’t prime (only 2 is even and prime); parity check doesn’t establish primality.