what will be the output of the following pseudo code? Set fun = 6 Set goal = 9…

2024

what will be the output of the following pseudo code?

Set fun = 6

Set goal = 9

Set sum1 = 0

Set n = 2

if (goal is greater than fun):

for(n=f; n

sum1=sum1+n

else:

Write Error messages

Write sum1

  1. A.

    18

  2. B.

    15

  3. C.

    10

  4. D.

    2

Attempted by 30 students.

Show answer & explanation

Correct answer: A

The output will be 18. The loop executes three times, incrementing sum1 in each iteration.

Explore the full course: Coding For Placement