Knowee
Questions
Features
Study Tools

QUESTION 01 bookmark_border Select the correct answer What will be the output of the following pseudo code? Integer p,q,r Set p=9, q=10, r=11 For (each r from 3 to 7) q =1+r if (6>p || (4+8)<(8+q)) q=2+r End if End for Print p+q radio_button_unchecked 22 radio_button_unchecked 18 radio_button_unchecked 31 radio_button_unchecked 13

Question

QUESTION 01 bookmark_border Select the correct answer What will be the output of the following pseudo code?

Integer p,q,r Set p=9, q=10, r=11 For (each r from 3 to 7) q =1+r if (6>p || (4+8)<(8+q)) q=2+r End if End for Print p+q radio_button_unchecked 22

radio_button_unchecked 18

radio_button_unchecked 31

radio_button_unchecked 13

🧐 Not the exact question you are looking for?Go ask a question

Solution

The output of the pseudo code will be 18.

Here's the step by step explanation:

  1. Initialize p=9, q=10, r=11.
  2. The for loop runs for each r from 3 to 7.
  3. In each iteration, q is first set to 1+r.
  4. Then, the if condition checks if 6 is greater than p (which is 9, so this condition is false) or if 12 is less than 8+q. Since q is set to 1+r in each iteration, the value of q changes in each iteration.
  5. The if condition will be true when r is 5 or more, because then q (which is 1+r) will be 6 or more, making 8+q greater than 12.
  6. When the if condition is true, q is set to 2+r. This will happen when r is 5, 6 and 7. So, at the end of the loop, q will be 2+7=9.
  7. Finally, p+q is printed, which is 9+9=18.

This problem has been solved

Similar Questions

QUESTION 01 bookmark_border Select the correct answer What will be the output of the following pseudo code? Integer p,q,r Set p=9, q=10, r=11 For (each r from 3 to 7) q =1+r if (6>p || (4+8)<(8+q)) q=2+r End if End for Print p+q radio_button_unchecked 22 radio_button_unchecked 18 radio_button_unchecked 31 radio_button_unchecked 13

QUESTION 02 bookmark_border Select the correct answer Find the output of the following pseudo-code: Integer value, n Set value = 1, n = 45 while(value less than equal to n) value = value *4 value/=2 end loop Print value radio_button_unchecked 64 radio_button_unchecked 32 radio_button_unchecked 44 radio_button_unchecked 45

QUESTION 07bookmark_borderSelect the correct answerFind the odd number out:2, 4, 6, 8, 10, 12, 14, 15, 21radio_button_unchecked15radio_button_unchecked21radio_button_unchecked2radio_button_uncheckedNone

QUESTION 05bookmark_borderSelect the correct answerComplete the following analogy.49 : 6:: ? : 4radio_button_unchecked64radio_button_unchecked36radio_button_unchecked25radio_button_unchecked16

QUESTION 09bookmark_borderSelect the correct answerFind the missing term in the following series: 8 : 510 :: 6 : ?radio_button_unchecked218radio_button_unchecked216radio_button_unchecked212radio_button_unchecked214

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.