Capgemini Pseudo Code

Questions 31: What will be the output of the following pseudo code for number = 3 ?

Integer prime( Integer number)
if ( number less than equal to 1)
return 1
else
return ( number * number * number + prime( number - 1))
End function prime()

  • Options
  • a : 36
  • b : 1
  • c : 23
  • d : 45
  • Answer: a

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

    Integer a, b, c

    Set b = 1
    Set a = b + 3
    Set c = 10
    if ( a )
    a = a - 2
    End if
    if ( a )
    a = 10
    End if
    a = a + b + c
    Print a + b

  • Options
  • a : 21
  • b : 22
  • c : 28
  • d : 11
  • Answer: b) 22

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

    Integer a, b, c
    Set a = 3, b = 2, c = 3
    If( a >> 1 && b>>1 )
    a = a << 1
    b = b + 1
    Else
    b = b >> 1
    c = c >> 2
    End if
    Print a + b - c

  • Options
  • a : 9
  • b : 12
  • c : 6
  • d : 3
  • Answer: c

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

    Integer a, b, c
    Set b = 10, a = 1
    if(0)
    a = a - 1
    Else
    a = b + 1
    b = a - 1
    a = a - 1
    End if
    Print a

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

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

        Integer a, b, c, d
        set d = 6;
        for ( each a from 1 to 2 )
    	    for( each b from a to 2 )
    		    for( each c from b to 2 )
    		        printf  d
    		end for
            end for
        end for
        

  • Options
  • a : 6 6 6 6 6 6
  • b : 6 6
  • c : 6 6 6
  • d : 6 6 6 6
  • Answer: d

    Questions 36: What will be the output of the following pseudo code for number = 3 ?

    Integer a, b, c
    set a = 108, b = 2, c = 3
    if( a MOD 9 ) EQUALS 0 )
    b = b + ( a MOD 2 )
    printf b
    else
    c = c + (a MOD 7 )
    printf c
    end if

    [Note : MOD finds the remainder after the division of the number by another]

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

    Questions 37: Which of the following values of 'a' the statement under if will excuted?

    Integer a
    if( a mod 10 > 5 OR a mod 10 equals 3 AND a/100 equals 1 )
    print a mod 10 + a/100
    else
    print a
    end

  • Options
  • a : 123
  • b : 555
  • c : 111
  • d : 121
  • Answer: a

    Questions 38: What will be output of following pseudocode which is given below for p=10 and q=11?

    Integer fun( Integer p, Integer q)
    Integer k
    Set k = 0
    if( p > 0 && q > 0 )
    k = k + 1
    fun (p-1, q)
    end if
    return k
    End function fun()

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

    Questions 39: What will be output of the following pseudocode for a = 6?

    Integer fun(integer a)
    if(a EQUALS 0)
    return a + 9
    else
    return fun(a-1)
    End function fun()

  • Options
  • a : 6
  • b : 9
  • c : 1
  • d : 0
  • Answer: b

    Questions 40: What will be the output of the folowing pseudocode?

    Integer i
    Set i = 45
    if( i mod 2 EQUALS 0 OR i mod 2 AND i )
    printf i mod 2
    else
    print i
    end if

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