Company: Infosys_27oct

Difficulty: medium

Problem Statement

What will be the output of the following pseudocode? Set Integer n = 5 Set Integer a = 3 Set Integer d = 0 While a <= 10   Set Integer c = n MOD a   d = d + c   a = a + 1 End-While Print d 23 28 30 25 What will be the output of the following pseudocode? Set Integer n = 20 Set Integer sum sum = addNumbers(n) Print "sum = " + sum Function addNumbers(n)   If n != 0     Return n + addNumbers(n - 1)   Else     Return n   End-if End-Function sum = 190 sum = 200 sum = 210 sum = 220 What will be the output of the following pseudocode? Set Integer x = 5 Set Integer k = 10 Set Integer s = 0 While k > x   s = s + 1   k = k - (x - 1)   x = x - 1 End-While Print s 1 2 3 4 What will be the output of the following pseudocode? Set Integer a = 6 While a < 10   a = a + 5 End-While If a > 20   Print a + (a + 1) Else   Print a - (a - 1)

More Infosys_27oct OA questionsInterview experiences