Capgemini Pseudo Code Questions Quiz-1

Question 1

Time: 00:00:00
What will be the space required for this piece of code?

int sum (int B[], int n)
{
int s = 0, j;
for (j = 0; j < n; j++)
s = s + B[i];
return s;
}// sizeof(int) = 2 bytes

2n + 8

2n + 8

2n + 4

2n + 4

2n + 2

2n + 2

2n

2n

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

PrepInsta User

2n+4

Question 2

Time: 00:00:00
What will be the output of the following pseudo code?

For input e = 7 & f = 8.
work (input e, input f)
If (e < f)
return work (f, e)
elseif (f != 0)
return (e + work (e, f - 1))
else
return 0

72

72

88

88

56

56

65

65

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 3

Time: 00:00:00
What will be the output of the following pseudo code?

Input p = 9, w = 6 ,
p = p + 1 ;
w = w - 1 ;
p = p + w
if (p > w)
print p
else
print w

6

6

5

5

10

10

15

15

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

PrepInsta User

m=9, n=6 m=9+1 =10 N=6-1 =5 m=10+5 =15 if(15>6) print 15 else print 6 so the answer is 15

PrepInsta User

option D is correct First the m=9, n=6 then the statement is m=m+1 that is 9+1=10 then the statement is n=n-1 that is 6-1=5 then m=m+n-> 10+5=15 then the if statement if true that is (m>.n) = 15>5; true. so print m, that is 15.

Question 4

Time: 00:00:00
What will be the output of the following pseudo-code?

Input t = 6, h = 9 and set x = 0 
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

21

21

15

15

9

9

6

6

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 5

Time: 00:00:00
What will be the output of the following pseudo code?

integer i
set i=3
do
print i+3
i=i-1
while( i not equals 0)
end while

6 5 4

6 5 4

6 5 6

6 5 6

5 5 5

5 5 5

6 6 6

6 6 6

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 6

Time: 00:00:00
What will be the output of the following pseudocode for input a = 30, b = 60, C = 90?
Integer a, b, c, sum
Read a, b, c
Set sum = a + b + c
if ((sum EQUALS 180) and (a NOT EQUALS 0) and (b NOT EQUALS 0) and (c NOT EQUALS 0))
Print " Success"
Otherwise
Print "Fail"
End if

success

success

fail

fail

compilation error

compilation error

None of the mentioned

None of the mentioned

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 7

Time: 00:00:00
What will be the output of the following pseudocode for a = 2, b = 6?

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

17

17

21

21

20

20

8

8

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 8

Time: 00:00:00
What will be the output of the following pseudocode?

Integer count
for (each count from 0 to 9)
print "#"
if (count > 6)
CONTINUE 
print count 
End for

#0#1#1#2#3#4#5#

#0#1#1#2#3#4#5#

0#1#1#2#3#4#5#6##

0#1#1#2#3#4#5#6##

#0#1#2#3#4#5#6

#0#1#2#3#4#5#6

#0#1#1#2#3#4#5#6#7#8#9#10

#0#1#1#2#3#4#5#6#7#8#9#10

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 9

Time: 00:00:00
What does the following piece of code do?

public void func (Tree root)
{
func (root.left ());
func (root.right ());
System.out.println (root.data ());
}

Preorder traversal

Preorder traversal

Inorder traversal

Inorder traversal

Postorder traversal

Postorder traversal

Level order traversal

Level order traversal

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

PrepInsta User

Post order Traversal : LEFT> RIGHT >ROOT

Question 10

Time: 00:00:00
Tree is a binary search tree. Which of the following code will help us to find the minimum element of Tree?

a) public void min (Tree root)
{
while (root.left () != null)
{
root = root.left ();
}
System.out.println (root.data ());
}



b) public void min (Tree root)
{
while (root != null)
{
root = root.left ();
}
System.out.println (root.data ());
}



c) public void min (Tree root)
{
while (root.right () != null)
{
root = root.right ();
}
System.out.println (root.data ());
}



d) public void min (Tree root)
{
while (root != null)
{
root = root.right ();
}
System.out.println (root.data ());
}

a

a

b

b

c

c

d

d

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

["0","40","60","80","100"]
["Need more practice!","Keep trying!","Not bad!","Good work!","Perfect!"]

Personalized Analytics only Availble for Logged in users

Analytics below shows your performance in various Mocks on PrepInsta

Your average Analytics for this Quiz

Rank

-

Percentile

0%

Get over 200+ Courses under One Subscription

mute

Don’t settle Learn from the Best with PrepInsta Prime Subscription

Learn from Top 1%

One Subscription, For Everything

The new cool way of learning and upskilling -

Limitless Learning

One Subscription access everything

Job Assistance

Get Access to PrepInsta Prime

Top Faculty

from FAANG/IITs/TOP MNC's

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.

Comments

30 comments on “Capgemini Pseudo Code Questions Quiz-1”