Capgemini Pseudocode Programming


1.What will be the output of the following pseudocode?

1.Declare variable f,g and i
2.Set f=0 and g=1
3.for(i=1;i<=3;i++)
    f=f+g
    g=f+1
    print f
end loop

a)0 0 1 2
b)1 3 7 15
c)0 2 6 14
d)Not of these


(b) is the correct option.


2.What will be the output of the following Pseudocode:

solve(arr,f,s,num)
if s>=l
    temp=f+(s-l)/2
    if arr[temp]==num
        return temp
    elif arr[temp]>num
        return solve(arr,f,temp-1,num)
    else
        return solve(arr,temp+1,s,num)
    endif
else
    return "Not Applicable"
endif

if arr=[3,4,2,1,4,5],num=6,f=0 and s=6:
a)6
b)2
c)Index Error
d)Not applicable


(d) is the correct option.


3.What will be the output of the following pseudocode?


Integer A
Assign A=2
if(A IS EQUAL TO 1)
    if(A IS EQUAL TO 0)
        Print(A)
    else
        print(B)
    end if
else
    print(C)
end if

a)B C
b)C
c)B
d)A


(b) is the correct option.


4.What will be the output of the following pseudocode?

Integer p=19,q=20,r=6
Integer c=q&p|p&r
c=c+r
r=q+c
Print p,q,r,c

a)19 20 0 0
b)19 20 19 20
c)19 20 44 24
d)19 20 33 56


(c) is the correct option.


5.What will be the output of the following pseudocode?


Integer a[]={19,3,14,63,23,53}
Integer i=0
for i=0 to 5
    a[i]=(*a+i)+*(a+i)
    if i%2==0
        a[i]=(*a+i)-*(a+i);
        print(a[i])
    end if
end for

a)0 0 0 0 0 0
b)4 -4 4 -4 4 -4
c)0 4 -14 66 -23 58
d)12 4 -34 -35 34 67


(c) is the correct option.