Capgemini Pseudo Code

Questions 11: What will be the output of the following pseudo code?

Integer a
Integer p
Set a=8
p=a+5/7*4
print p*8

  • Options
  • a : 0
  • b : 64
  • c : 7
  • d : 8
  • Answer: b

    Questions 12: What will be the output of the following pseudo code for a=50?

    Integer fun( Integer a)
    Integer b
    Set b = 10
    Return a-b
    End function fun()

  • Options
  • a : 50
  • b : 40
  • c : 60
  • d : None
  • Answer: b

    Questions 13: What will be the output of the following pseudo code ?

    Integer x, y, z
    Set x=0, y=1
    For( each z from 0 to 2 )
    x = x + y + z
    End for
    print x

  • Options
  • a : 5
  • b : 6
  • c : 7
  • d : 8
  • Answer: b

    Questions 14: What will be the output of the following pseudo code ?
    ( Note : mod finds the remainder after division of one number by another. ^ is the bitwise XOR operator here )

    Integer i, j, k, m
    Set j = 6, i = 8, k = 7, m = 1
    If (( i^j ) mod k EQUALS 0 )
    m = m + 1
    else
    m = m – 1
    End If
    Print m

  • Options
  • a : 3
  • b : 0
  • c : 1
  • d : 2
  • Answer: d

    Questions 15: What will be the output of the following pseudo code for input 134 ?

    Integer fun( Integer num )
    Static Integer a = 0
    If (num > 0)
    a = a + 1
    fun ( num /10 )
    Else
    Return a
    End Function

  • Options
  • a : 8
  • b : 2
  • c : 3
  • d : 431
  • Answer: c

    Questions 16: What will be the output of the following pseudo code?

    Integer a, b, c
    Set a = 3, b = -2
    if ( b – 1 > b )
    for ( each c from 1 to 2 )
    a = a – 1
    If ( c > 0 )
    Jump out of the loop
    End If
    Continue
    a = a + 1
    a = a – 3
    a = a + 2
    End For
    End If
    Print a + b

  • Options
  • a : 1
  • b : 4
  • c : 5
  • d : 12
  • Answer: a

    Questions 17: What will be the output of the following pseudo code?

    Integer j, m
    Set m = 2
    Integer a[4] = { 2, 4, 2, 2 }
    If ( a[1] > 3 )
    a [1] = a [2]
    End If
    If (1)
    a [2] = a [1] + 2
    End If
    m = m + a[3] + a[2]
    Print m

  • Options
  • a : 2
  • b : 8
  • c : 1
  • d : 7
  • Answer: b

    Questions 18: What will be the output of the following pseudo code?

    Integer a, b, c
    Set a = -3, b = -2
    if ( b – 1 > b )
    for ( each c from 1-1 to 1-2 )
    If ( c < 0 )
    Jump out of the loop
    End If
    a = a + b
    End For
    End If
    Print a + b

  • Options
  • a : 12
  • b : 5
  • c : -5
  • d : 4
  • Answer: c

    Questions 19: What will be the output of the following pseudo code?

    Integer a, b, c
    Set a = 5, b = 3
    For ( each c from b to a )
    If ( a )
    a = a -1
    End if
    If ( b )
    b = b -1
    End if
    End for
    Print a + b

  • Options
  • a : 8
  • b : 4
  • c : 6
  • d : 7
  • Answer: b

    Questions 20: What will be the output of the following pseudo code?

    Integer a, b, c
    Set b = 10, a = 20, c = 20
    a = a – c
    c = c + a
    Print b + c

  • Options
  • a : 27
  • b : 4
  • c : 30
  • d : 8
  • Answer: c