Company: Infosys_27oct

Difficulty: medium

Problem Statement

Trace through this pseudocode and determine what gets printed. 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 Work out what this pseudocode prints when it finishes running. 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 Step through this pseudocode and figure out its printed result. 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 Evaluate this pseudocode and identify what it prints. Set Integer a = 6 While a < 10   a = a + 5 End-While If a > 20   Print a + (a + 1) El

More Infosys_27oct OA questionsInterview experiences