What will be the output of the following pseudo code?1. Integer p, q, r2. Set p=4, q=2, r=63. if((q-p-r) < (r - q))4. r=(q+p) & q5. End if6. r =3+q7. r =3+q8. r =3+q9. print p+q+r
Question
What will be the output of the following pseudo code?1. Integer p, q, r2. Set p=4, q=2, r=63. if((q-p-r) < (r - q))4. r=(q+p) & q5. End if6. r =3+q7. r =3+q8. r =3+q9. print p+q+r
Solution
The output of the pseudo code will be 10. Here's the step by step explanation:
- The variables p, q, and r are set to 4, 2, and 6 respectively.
- The condition in the if statement, (q-p-r) < (r - q), translates to (2-4-6) < (6 - 2), which is -8 < 4. This condition is true.
- Since the condition is true, the code inside the if statement is executed. r is set to the result of (q+p) & q, which is (2+4) & 2. The & operator performs a bitwise AND operation. The binary representation of 6 (which is 2+4) is 110 and of 2 is 10. The result of the bitwise AND operation is 10, which is 2 in decimal.
- After the if statement, r is set to 3+q three times. Since q is 2, r is set to 5 each time.
- Finally, p+q+r is printed, which is 4+2+5 = 11.
Similar Questions
What will be the output of the following pseudo code ?1.Integer p,q,r2. Set p=6, q=6, r=43.if(r<p || (p-r)< (q+p))4. p=(p+9)+p5. if((4^q^9)<(9^4))6. p=2+r 7. End if8. p=(p+9)+q9. End if10. Print p+q+r
What will be the output of the following pseudocode?Integer p, q, rset p= 1, q= 1, r= 2q = p - 1q = r - 1if (p + 2 > q -6)if (q+2 > p- 6)p = 2end ifq= 2if (r> 5)p = qend ifend ifprintf p + q + r
What will be the output of the following pseudo code?1. Inteter a, b, c2. Set a=9, b=4, c=93. if ((b&a)<a)4. a=b&a5. End if6. Pring a+b+c
What will be the output of the following pseudocode?Integer p, q, r Set p = 0, q = 4, r = 3 If(p || r) If(p && r) p = p &r End If p = p ^ r End If Print p + q + r
What will be the output of the following pseudocode?Integer p, q, r, s Set p=1, q = 1for (each r from 0 to 2 ) for (each s from -4 to -2 ) p = p + 2if(p > r) Continue End if p = 1if(p > s) Jump out of the loop End if End for End for Print p + qQuestion 83AnswerA.13B.24C.35D.20
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.