Capgemini 2024 - Pseudo Code Trainer Handout Set 2
Capgemini 2024 - Pseudo Code Trainer Handout Set 2
1
5. How do you initialize an array?
a) int arr[3]=(1,2,3) b) int arr(3)={1,2,3}
c) int arr[3]={1,2,3} d) int arr(3)=(1,2,3)
Explanation: Syntax to initialize an array int arr[3]={1,2,3}
8. Pseudocode is ____.
a) data that have been encoded for security.
b) the incorrect results of a computer program.
c) a program that doesn’t work.
d) a description of an algorithm similar to a computer language.
2
End
a) Addition b) Multiplication c) Summation d) None of the mentioned
Explanation: Addition is usually used to denote summation of 2 numbers, whereas summation is used for
sequences of numbers.
a) 4 b) 0 c) 0.5 d) 1
Explanation: 0, data bits are lost for the above shift operation hence the value is 0.
a) A b) Garbage value c) 65 d) 97
Explanation: 65, as the union variables share common memory for all its elements, x gets ‘A’ whose ASCII
value is 65 and is printed.
3
13. What will be the output of the following pseudocode?
a) 0 b) 1 c) 2 d) 4
Explanation: Make shift operation for given value
14. What will be the output of the following pseudocode for n =8?
a) 32 b) 16 c) 8 d) 12
Explanation: Recursion call will return the value of 2*(2*(4)) =16
a) 18 23 45 56 4 6 45 b) 18 23 45 56 4 c) 23 45 56 4 6 45 d) Error
Explanation: for loop will run till i<=x-2.
a) 11 5 b) 8 5 c) 7 9 d) 13 7
Explanation:
for loop will run till conditions gets a<=4.
4
for(a=1;a<=4;a++){
c = a + b;
if(((b + c) % 10) != 0)
c = c + a;
else
d = d + a;
}
20. The output of an AND gate with three inputs, A, B, and C, is HIGH when ________.
a) A = 1, B = 1, C = 0 b) A = 0, B = 0, C = 0 c) A = 1, B = 1, C = 1 d) A = 1, B = 0, C = 1
5
a) Fffffffe b) Fffe c) dependent on the compiler d) Error
Explanation: Output is dependent on the compiler. For 32 bit compiler it would be fffffffe and for 16 bit it
would be fffe.
getchar();
return 0;
}
a) 0 b) 1 c) Compiler error d) runtime error
Explanation: Since y is equal to z, value of the expression y == z becomes 1 and the value is assigned to x
via the assignment operator.
6
25. What will be the output/error?
7
a) 0 b) 10 c) 18 d) 14
Explanation: All three for loop will run till all conditions gets false. Also need to check the if condition
S%2==0. So the count value will be 18
28. What will be the output of the following pseudocode for x = 3 and y =2?
a) 8 5 2 b) 4 5 6 c) 7 6 5 d) 8 7 3
Explanation: The function fun() calculates and returns ((1 + 2 … + x-1 + x) y+3) which is (x-1,y+3)
a) 3 -13 b) 6 -6 c) 3 4 d) 12 -6
Explanation: Ans c=6 and d=-6
a) 9 b) 8 c) 18 d) 19
8
a) 1 2 3 4 5 b) 1 2 3 4 c) Compile Time Error d) Stack Overflow
Explanation: Stack Overflow, It is thrown when the amount of call stack memory allocated by JVM is
exceeded.
33. What will be the data type of the result of the following operation?
(float)a * (int)b / (long)c * (double)d
a) Int b) Long c) Float d) double
Explanation: It will return the value in Double
34. Consider a B-tree of order 4 and is built from scratch by 10 successive insertions. What would be the
maximum number of node splitting operations that take place?
a) 6 b) 3 c) 4 d) 2
Explanation: A B-tree of order m contains n records and each contains b records on average then the tree will
have about n/b leaves. If we split k nodes along the path from leaves then
9
k<=1+logm/2 [n/b]
here n=10,b=3,m=4 so
k<=1+log4/2 [n/b]
k<=1+log2 4
k<= 1+2
k<=3
35. Which of the following logic is used to produce loops in program logic when one or more instruction
may be executed several times depending on some conditions?
a) Iteration Logic b) Selection Logic c) Sequence Logic d) Decision Logic
10
Print b
Print c
Print d
a) Can’t be determined b) 160 2 320 1 c) 40 2 320 0 d) 1 2 3 4
Explanation: Once all shift operator are done, answer will be 160 2 320 1
11