Capgemini Pseudocode Questions
What will be the output of the following pseudocode?
Question 1) What will be the output of the following pseudocode for a=8, b=1?
Integer funn(Integer a, Integer b)
If(a > b && a > 0)
Return a + b + funn (b-1, a-1)
End if
Return a + b
Answer: 16Question 2) What will be the output of the following pseudocode for p=7, q=2?
Integer funn(Integer p, Integer q)
if(p + q < 10)
Return 1 + funn(p + 1, q + 1)
Else
Return 2
End if
Answer: 3Question 3) What will be the output of the following pseudocode for a=2, b=7, c=7?
Integer funn(Integer a, Integer b, Integer c)
if ((b + a) < (a – b))
a = a + c
b = (10 + 10) + c
End if
Return a + b + c
Answer: 16Question 4) What will be the output of the following pseudocode?
String str1 = “err”, str2 = “krr”
Print (count consonant(upper(reverse(str2) + reverse(str1))))
Answer: 5Question 5) What will be the output of the following pseudo code?
Integer a, b, c
Set a = 2, b = 11, c = 5
if ((4 + 5) < (6 + b))
b = c & a
End if
Print a + b + c
Answer: 7
What is PseudoCode: A Complete Tutorial
A Pseudocode is defined as a step-by-step description of an algorithm. Pseudocode does not use any programming language in its representation instead it uses the simple English language text as it is intended for human understanding rather than machine reading.
Pseudocode is the intermediate state between an idea and its implementation(code) in a high-level language.