0% found this document useful (0 votes)
105 views15 pages

Cap Gemini 1

Uploaded by

Kaushiki Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views15 pages

Cap Gemini 1

Uploaded by

Kaushiki Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Q1. What will be the output of following pseudocode?

For input e = 7 & f = 9.

work (input e, input f)

If (e < f)

return work (f, e)

elseif (f != 0)

return (e + work (e, f - 1))

else

return 0

a)56
b)54
c)63
d)90

Q2. What will be the output of following pseudocode?

Input t = 6, h = 9 and set x = 2

Integer c

if (h > t)

for (c = t; c < h; c = c + 1)

x=x+c

End for loop

print x

else

print error message print x


a)21
b)23
c)20
d)15
Q3. Consider an array of float. Calculate the difference between the address of the 1st and
6th element, assuming float occupies 4 bytes of memory.

a)24 bytes
b)20 bytes
c)15 bytes
d)12 bytes

Q4.With the given information provided find out the address of Arr[17] in a 1-D array
Arr[30].

- lower bound = 0

- starting base address = 1100

- size of each element is 2.

a)1132

b)1134

c)1128

d)1068

Q5.

Find out the array representation of the given min heap, if the value 7 is added to it.

1,6,8,90,56,23

a) 1,6,8,90,56,23,7
b) 1,6,7,90,56,23,8
c) 1,7,6,8,90,56,23
d) 1,7,8,90,56,23,6

Q6. If the base address of two dimensional array A[70] [10] is 500, then find out the address
of an
element A[2][7] in the array.

** Assume 4 words per memory cell and elements are arranged in column major order.

a) 2458
b) 2543
c) 2468
d) 2368

Q7 If there is a binary tree of height 10, then what should be the maximum number of
nodes in that
tree?

a)1023

b)1024

c)1022

d)1000

Q8. What will be the output of following pseudocode?


Integer a,b,c
Set a=6 , b=8, c=10
For (each c from 2 to 4)
b=(2+5)+b
if (8+2)<(6+b)
b=b+b
a=a^17

else
a=a&1
endif
a=8+7+c
End for
Print a+b

a) 59
b) 181
c) 87
d) 72

Q9. What will be the output of following pseudocode?


Integer p,q,r
Set p=7 q=3 and r=8
For (each r from 3 to 6)
p=(5+11)^q
if((q+r)>(r-q))
q=(7+9)+r
p=p+q+r
else
q=10*q+r
break out of loop
End if
End for
Print(p+q)
a)55
b)59
c)56
d)65

Q10.Convert the following prefix to postfix expression


+A-B+*C/DFG
a) ABCDF/*G+-+
b) ABC/*DFG-+-
c) ABCDF/*G-+-
d) ABCDFG+-+/*

Q11. What will be the output of following pseudocode?


a=3 b=1
Integer funn(Integer a, Integer b)
if(a > 0)
if(b > 0)
return a + b + funn(a + 1, b-1) + funn(a + 2, b-1) + funn(a + 3, b-
1)
End if
End if
return a + b
End function funn()

a) 20
b) 21
c) 17
d) 12

Q12 Find out the array representation of the given min heap, if the value 0 is added to it.
1,99,45,120,250,100
a) 0,1,99,45,120,250,100
b) 0,99,1,120,250,100,45
c) 1,99,45,120,250,100,0
d) 0,99,1,120,250,45,100

Q13. Convert the infix expression to postfix


(A+B)*C/D+U-Z/R*T
a) AB+C*D/U-ZR/T*+
b) AB*CD/+U+ZR/T*-
c) AB*CD/+U*ZR/T*-
d) AB+C*D/U+ZR/T*-

Q14. What will be the output of following pseudocode?

Integer a, b, c
Set b = 1321, a = 1
c=a^b
c=c&1024
c=c|3
Print c

a) 1321
b) 1300
c) 1320
d) 1026

Q15. What will be the output of following pseudocode?

Integer value n=80 x=0


While(x is less than 80)
X=X<<1
End while
Print x
a. 64
b. 63
c. 128
d. 100

Q16. If we draw a binary search tree by inserting the given numbers from left to right. then
what would
be the height of the BST?
7,37,15,1,2,49
a)3
b)5
c)6
d)4

Q17.

void swap ( int &x, int &y )


{
int tmp;
tmp = x;
x = y;
y = tmp;
}

In order to exchange the values of two variables a and b:

a) Call swap (a, b)


b) Call swap (&a, &b)
c) swap(a, b) cannot be used as it does not return any value
d) swap(a, b) cannot be used as the parameters passed by value

Q18.What is the output of the following code;

#include<stdio.h>

int main()

int a,*p1,**p2,***p3,****p4,*****p5;

a=17;

p1=&a;

p2=&p1;

p3=&p2;

p4=&p3;

p5=&p4;
printf("%d\t",*p1);

printf("%d\t",**p2);

printf("%d\t",***p3);

printf("%d\t",****p4);

printf("%d\t",*****p5);

a) 10 11 12 13 14
b) 10 10 10 10 10
c) 17 17 17 17 17
d) Error

Q19.What will be the output.

#include<stdio.h>

#include<string.h>

void main()

char ch='d';

int i=0;

while(ch>='a' && ch<='g')

i++;

ch++;

printf("%d\t",i);

printf("%d\t",ch);

printf("%c",ch);
}

a) 4 104 h

b) 5 102 f

c) 5 102 g

d) 5 104 f

Q20. What will be the output of following pseudocode?

Counter=0,i
For i (0 to8 << 2)
Counter = Counter + 2
END For
Print Counter

a)58

b)56

c)64

d)66

Q21. If the base address of two dimensional array A[80] [20] is 700, then find out the
address of an
element a[1][9] in the array.
** Assume 4 words per memory cell and elements are arranged in column major order.
A. 3249
B. 3268
C. 6547
D. 3460
Q22.
Which of the following is the correct order of the nodes visited during an pre-order
traversal of the given nodded tree?

a)A->B->D->C->E->G->H->I->J
b) A->B->D->C->E->F->G->H->I
c) A->B->C->D->E->G->F->H->I
d) A->B->D->C->E->G->F->H->I

Q23.What will be the output of the given code.


Integer p,q,r
Set p=9, q=10 , r=17
For (each r from 3 to 7)
q=1+r
if ( 6>p || (4+8)<(8+q))
q=2+r
End if
End for
Print p^q
a)0
b)9
c)18
d)17
Q24.
Integer a,b,c
Set a=6, b=8, c=10
For (each c from 2 to 4)
b=2+5+a
If((8+3)<(6+b))
b=b+b
a=10&c
Else
Break
End if
a=(8+5)+c
End for
Print a+b
a)63
b)69
c)56
d)71

Q25. Evaluate the given postfix expression.


23+5*23+5+*
a) 210
b) 225
c) 250
d) 200

Q26.

a=15 b=6

Integer funn(Integer a, Integer b)


if(a > 1)
return a * funn (b - 6, a - 4)
Else
return 1
End if
return a + b
End function funn()

a) 23
b) 15
c) 4
d) 17

Q27.
Integer p, q, r
Set p= 4, q =1, r = 2
if(p+ (2&2&2) && q + (3&3&3) && r + (2^2^2))
p=p-2
q=p
Else
p=r
q=q^2
End if
Print p+ q+ r

a) 8
b) 4
c) 16
d) 6

Q28. What will be the output of following function?


n=127,i=0,s=0

Function Sample(int n)

while(n>0)

r=n%10

p=8^i

s=s+p*r

i++
n=n/10

End While

Return s;

End Function
a)87
b)84
c)63
d)100

Q29.
Set a=65, b=105
Function answer(a, b)

t=0

while (b != 0):

t=t+a

b=b-1

End While

return t

End Function

a)7995
b)6820
c)6825
d)7990

Q30. What will be the output of following code?

#include <iostream>

using namespace std;

int main()

{
int a = 32, *ptr = &a;

char ch = 'B', &cho = ch;

cho += a;

*ptr += ch;

cout << a << ", " << ch << endl;

return 0;

a)130,b
b)129,a
c)130,a
d)129,c
ANSWERS
1-c
2-b
3-b
4-b
5-b
6-c
7-a
8-b
9-a
10-a
11-b
12-b
13-d
14-d
15-c
16-a
17-a
18-c
19-a
20-d
21-b
22-d
23-a
24-a
25-c
26-b
27-d
28-b
29-c
30-a

You might also like