Knowee
Questions
Features
Study Tools

What will be the value of the following pseudocode for k=150?fun(integer k)if(k>155)returnend ifprint kfun(k+2)print kEnd of function fun()

Question

What will be the value of the following pseudocode for k=150?fun(integer k)if(k>155)returnend ifprint kfun(k+2)print kEnd of function fun()

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

Solution

The pseudocode provided is a recursive function that prints the value of k and calls itself with k+2 until k is greater than 155. Here's how it would execute for k=150:

  1. Call fun(150). Since 150 is not greater than 155, it will print 150 and call fun(152).
  2. Call fun(152). Since 152 is not greater than 155, it will print 152 and call fun(154).
  3. Call fun(154). Since 154 is not greater than 155, it will print 154 and call fun(156).
  4. Call fun(156). Since 156 is greater than 155, it will return and not print anything.
  5. After each function call returns, it will print k again. So it will print 154, 152, and 150 in that order.

So, the output of the pseudocode for k=150 will be 150, 152, 154, 154, 152, 150.

This problem has been solved

Similar Questions

What will be the output of the following pseudocode for p = 6, q = 27Integer funn ( integer p, integer q )if ( p> 0 )return p + q + funn ( p - 3, q ) + funn (p-8, q-2 )end if return q - 2end function funn ( )

What will be the output of the following pseudocode for a = 10, b = 11?Integer funn(Integer a, Integer b)if(0)return a - b - funn(-7, -1)End ifa = a + a + a + areturn aEnd function funn()Question 82AnswerA.30B.44C.0D.40

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 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

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

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.