What will be the output of the following pseudo code ? Integer a,b,c Set a=7, b=4, c=8 if((b-c+a)<(a+b)) if((a^c^7)<(4+b+a)) b=c+c for (each c from 2 to 4 ) a=(b+c)&b End for Else a=(a&a)+b End if a=(a^12)+a End if Print a+b+c radio_button_unchecked 35 radio_button_unchecked 64 radio_button_unchecked 44 radio_button_unchecked 56
Question
What will be the output of the following pseudo code ?
Integer a,b,c Set a=7, b=4, c=8 if((b-c+a)<(a+b)) if((a^c^7)<(4+b+a)) b=c+c for (each c from 2 to 4 ) a=(b+c)&b End for Else a=(a&a)+b End if a=(a^12)+a End if Print a+b+c radio_button_unchecked 35
radio_button_unchecked 64
radio_button_unchecked 44
radio_button_unchecked 56
Solution
Let's break down the pseudo code:
- Initialize a=7, b=4, c=8.
- Check if (b-c+a) < (a+b), which translates to (4-8+7) < (7+4), or 3 < 11. This condition is true, so we enter the if statement.
- Check if (a^c^7) < (4+b+a), which translates to (7^8^7) < (4+4+7), or 2 < 15. This condition is true, so we enter the nested if statement.
- Set b = c + c, which translates to b = 8 + 8, or b = 16.
- For each c from 2 to 4, set a = (b+c) & b. This will run three times:
- For c = 2, a = (16+2) & 16, or a = 18 & 16, or a = 16.
- For c = 3, a = (16+3) & 16, or a = 19 & 16, or a = 16.
- For c = 4, a = (16+4) & 16, or a = 20 & 16, or a = 16.
- Set a = (a^12) + a, which translates to a = (16^12) + 16, or a = 4 + 16, or a = 20.
- Print a + b + c, which translates to 20 + 16 + 8, or 44.
So, the output of the pseudo code will be 44.
Similar Questions
what wiil be the output of the following pseudo code?Integer a,b,cSet a=2,b=7, c=9if(9>c || (b&a)<a) c=(b+1)+bElse a=a+c b=5^bEnd ifPrint a+b+c
What be the output of the following pseudocode?Integer a, b, cSet a = 4, b = 4, c = 4if (a & (b ^ b) & c)a = a >> 1End ifPrint a + b + cQuestion 74AnswerA.8B.12C.24D.16
What will be the output of the following pseudo code ? Integer a,b,c Set a=7, b=4, c=8 if((b-c+a)<(a+b)) if((a^c^7)<(4+b+a)) b=c+c for (each c from 2 to 4 ) a=(b+c)&b End for Else a=(a&a)+b End if a=(a^12)+a End if Print a+b+c radio_button_unchecked 35 radio_button_unchecked 64 radio_button_unchecked 44 radio_button_unchecked 56
What will be output of the following pseudo code ?Integer a, b, c Set a=3, b=4,c=10a=10+b if ((a+b+c)<(b+c+a)) a=(3+9)+c if ((b+a+7)<(5+c+b)) c=(b+11)+c Else a=(8+5)+a End if b=(2+2)+bElse if ((b+c)<(c-b)) b=(a+b)+b c=c+b End if a=10+bEnd if print a+b+c
What will be the output of the following pseudocode?Integer a, b, cSet a = 1, b = 1for(each c from 4 to 7) if(a > c ) a = a - 1 Jump out of the loop Else a = a + c if(c) a = a + 1 End if End if End for Print a + b[Note: If(x) gets executed if the value inside if(), i.e., x is not zero.]
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.