Capgemini Pseudo Code

Questions 21: What will be the output of the following pseudo code for a=34?

Integer fifo(Integer a)
If ( a equals 1 )
return a + 9
Else
return fifo( a/5+ a/35)
End if
End Function fifo()

  • Options
  • a : 20
  • b : 10
  • c : 12
  • d : 22
  • Answer: b

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

    Integer a, b, c, s
    Set a = 16, b = 23, c = 7
    s = ( a + b ) && ( a – b ) || ( a * c )
    if ( s not equals 0 )
    print s + a – b * c
    else
    print s + s
    end if

  • Options
  • a : -23
  • b : 144
  • c : -144
  • d : 23
  • Answer: c

    Questions 23: What will be the output of the following pseudo code for a = 132 and b = 41?

    Integer funn( Integer a, Integer b)
    a = a + b
    b = a – b
    return b + a
    End function funn()

  • Options
  • a : 360
  • b : 0
  • c : 300
  • d : 305
  • Answer: d

    Questions 24: What will be the output of the following pseudo code for a =12, b = 41?

    Integer funn( Integer a, Integer b)
    if ( a - b )
    return b + a
    Else
    return a - b
    End if

  • Options
  • a : -29
  • b : 29
  • c : -53
  • d : 53
  • Answer: d

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

    Read Integer
    j=41, k= 37
    j=j+1
    k=k-1
    j=j/k
    k=k/j
    print(k,j)

  • Options
  • a : 42 36
  • b : 36 1
  • c : 1 1
  • d : 1 36
  • Answer: b

    Questions 26: What will be the output of the following pseudo code for s = 8 ?

    Integer shift(Integer s)
    if ( s is greater than equal to 3)
    return shift( s >> 1 )
    else
    return s
    end if
    End function shift()

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

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

    Integer a, b, c
    Set b = 2, a = 1
    for ( each c from 1 to 1 )
    a = a * c
    b = b* c
    End for
    If ( (1&4) || ( 1^1) || (2^1) )
    b = a - 1
    a = a - 1
    Else
    b = a ^ 1
    a = a ^ 1
    End if
    Print a + b + c

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

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

    Integer a, b
    Set a = 7
    b = 10 ^ a
    if ( a & b )
    a = a >> 2
    End if
    a = a - b
    Printf a + b

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

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

    Integer a, b, c, d
    Set a = 3, b = 1, c = 3
    for ( each d from 1 to 3 )
    if ( d > 2)
    a = a - b
    b = a
    End if
    End for
    Print a + c

  • Options
  • a : 1
  • b : 5
  • c : 6
  • d : 3
  • Answer: b

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

    Integer a
    String str1
    Set str1 = "goose"
    a = stringLength(str1)
    Print a

  • Options
  • a : 2
  • b : 4
  • c : 5
  • d : 10
  • Answer: c