Capgemini pseudocodes asked on 18th december 2021 | slot 2

Capgemini Pseudo Code MCQs (previously asked)

Capgemini pseudocodes asked on 18th december 2021 slot 2


1)What will be the output of the following pseudocode?
#include
int main()
{
char ch = 'A';
printf("%d\n", ch);
return 0;
}

a) A
b)'A'
c) 65
d) 97

Ans: Option a

2)What will be the output of the following pseudocode?
#include
int foo(int* a, int* b)
{
int sum = *a + *b;
*b = *a;
return *a = sum - *b;
}
int main()
{
int i = 0, j = 1, k = 2, l;
l = i++ || foo(&j, &k);
printf("%d %d %d %d", i, j, k, l);
return 0;
}

a) 1211
b) 1121
c) 1221
d) 1222

Ans: Option a

3) What will be the output of the following pseudocode?
#include
int i;
int main()
{
if (i);
else
printf("Ëlse");
return 0;
}

a) if block is executed.
b) else block is executed
c) It is unpredictable as i is not initialized.
d) Error: misplaced else

Ans: Option b

4)What will be the output of the following pseudocode?
Integer i
Set i = 3
do
print i + 3
i = i - 1
while(i not equals 0)
end while

a) 666
b) 656
c) 555
d) 654

Ans: Option d

Click here for detailed explanation

5)What will be the output of the following pseudocode for n=127?
Read n
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) 27
b) 187
c) 87
d) 120

Ans: Option C

6)What will be the output of the following pseudocode if limit =6 ?
n1 = 0, n2= 1, n3=1, count = 1;
while count <= limit
count=count+1
print n3
n3 = n1 + n2
n1 = n2
n2 = n3
End While

a) 112358
b) 12358
c) 1123581321
d) 12358132

Ans: Option A

7) What will be the output of the following pseudocode ?
Function divisible(number)
even_counter = 0, num_remainder = number;
while (num_remainder)
digit = num_remainder % 10;
if digit != 0 AND number % digit == 0
even_counter= even_counter+1
End If
num_remainder= num_remainder / 10;
End While
return even_counter;

a) 3
b) 4
c) 2
d) 1

Ans: Option d

8) What will be the output of the following pseudocode if a = 65, b =123?
Function answer(a, b)
t = 0
while (b != 0):
t = t + a
b=b-1
End While
return t
End Function

a) 6995
b) 7995
c) 8995
d) None of the mentioned

Ans: Option b

For more pseudo codes click here

Comments

Post a Comment

Popular posts from this blog

Capgemini Analyst Interview Experience | Experience 2

Capgemini Pseudocode Question Asked on 19th december 2021 | slot 2

Capgemini Pseudocodes MCQs Part 2