Start Read n1, n2 If n1 > n2 then Print n1 Else Print n2 End if Stop What will…

2018

Start

Read n1, n2
If n1 > n2 then
Print n1

Else


Print n2
End if
Stop

What will be the output if we change the condition to n1<n2?

  1. A.

    n1 will be displayed

  2. B.

    Largest of the two numbers will be displayed

  3. C.

    Smallest of the two numbers will be displayed

  4. D.

    n2 will be displayed

Attempted by 243 students.

Show answer & explanation

Correct answer: C

The original algorithm prints the larger number. Changing the condition from n1 > n2 to n1 < n2 reverses the logic. Now, if n1 is smaller than n2, it prints n1; otherwise, it prints n2. Consequently, the algorithm will always output the smallest of the two numbers, making option C correct.

Explore the full course: Btsc Lab Assistant