hamburger menu
All Coursesall course arrow
adda247
reward-icon
adda247
    arrow
    arrow
    arrow
    Start set num = 0 display " enter the number" read num if ( remainder (num / 2 ) = 0 ) display "yes" else display "no" end If the ou
    Question

    Start
    set num = 0
    display " enter the number"
    read num
    if ( remainder (num / 2 ) = 0 )
    display "yes"
    else
    display "no"
    end
    If the output of the above algorithm is "yes", it indicates that num is:

    A.

    Even number

    B.

    Amstrong number

    C.

    Odd number

    D.

    Prime number

    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.
    Important Key Points

    1. Even test: num % 2 == 0 ⇔ even; num % 2 == 1 (or != 0) ⇔ odd (for nonnegative integers).
    2. Negative numbers: Even/odd parity still holds: e.g., -4 % 2 == 0 → even.
    3. No primality check: Primality requires divisibility tests beyond 2; not done here.
    4. No Armstrong check: Armstrong (narcissistic) numbers involve sum of powered digits; unrelated.
    5. I/O flow: Prompt → read → parity check → print "yes"/"no".
    6. 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.

    Free Tests

    Free
    Must Attempt

    Government Policies and Scheme

    languageIcon English
    • pdpQsnIcon10 Questions
    • pdpsheetsIcon20 Marks
    • timerIcon5 Mins
    languageIcon English
    Free
    Must Attempt

    Government Schemes

    languageIcon English
    • pdpQsnIcon10 Questions
    • pdpsheetsIcon20 Marks
    • timerIcon5 Mins
    languageIcon English
    Free
    Must Attempt

    SSC GD PYP (Held on 4 Feb 2025 S1)

    languageIcon English
    • pdpQsnIcon80 Questions
    • pdpsheetsIcon160 Marks
    • timerIcon60 Mins
    languageIcon English
    test-prime-package

    Access ‘UPSSSC’ Mock Tests with

    • 60000+ Mocks and Previous Year Papers
    • Unlimited Re-Attempts
    • Personalised Report Card
    • 500% Refund on Final Selection
    • Largest Community
    students-icon
    368k+ students have already unlocked exclusive benefits with Test Prime!
    Our Plans
    Monthsup-arrow