What will be the output of the following pseudo code a=3, b=2?1. 2. Integer funn (Interger a, Integer b)3. if(b<4 && a<4)4. b=b+35. b=(a+c)+b6. return funn (a+1,b) + funn(b, a)-a7. End if8. return a+b -1
Question
What will be the output of the following pseudo code a=3, b=2?1. 2. Integer funn (Interger a, Integer b)3. if(b<4 && a<4)4. b=b+35. b=(a+c)+b6. return funn (a+1,b) + funn(b, a)-a7. End if8. return a+b -1
Solution
The pseudo code you provided seems to have some issues. There is no variable 'c' defined before it is used in line 5. Also, the function 'funn' is recursively called in line 6 without a clear base case, which could lead to an infinite loop.
However, I'll try to explain the logic of the code as it is:
- The function 'funn' is defined to take two integer parameters, 'a' and 'b'.
- If 'b' is less than 4 and 'a' is less than 4, the following steps are executed:
- 'b' is incremented by 3.
- 'b' is set to the sum of 'a', 'c', and the new value of 'b'. But since 'c' is not defined, this will cause an error.
- The function 'funn' is recursively called twice with different parameters and the results are added together and then subtracted by 'a'. But since there is no base case for the recursion, this will likely cause an infinite loop.
- If 'b' is not less than 4 or 'a' is not less than 4, the function returns the sum of 'a' and 'b' minus 1.
Without the definition of 'c' and a base case for the recursion, it's not possible to predict the output of this code.
Similar Questions
What will be the output of the following pseudo code a=2, b=1?1. 2. Integer funn (Interger a, Integer b)3. if(4>b && b<a && b<a)4. a=b+25. a=b+26. b=a+17. return b – funn(b, b)8. End if9. b=1+b+a10. return b-a +1
What will be the output of the following pseudocode for a = 4 and b = 9?Integer funn(Integer a, Integer b)If(a Return 1 + funn(a, b – 2)End IfIf(a^b >a &b)Return a ^ bElseReturn a &bEnd IfReturn 1End function funn()10-81424
What will be the output of the following pseudocode for a = 4, b = 6?Integer funn(Integer a, Integer b) If(a > 1) Return a * funn (b - 6, a - 4) Else Return 1 End If Return a + b End function funn()Question 79AnswerA.7B.17C.4D.0
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 for a = 5, b = 1?Integer funn(Integer a, Integer b)if(b + a || a - b) && (b > a) && 1)a = a+b+b-2return 3-aElseEnd ifreturn a-b+1return a+b End function fun()Question 77AnswerA.11B.5C.16D.0
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.