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

2n+4

Start

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

Start

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

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

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.

Start

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

Start

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

Start

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

Start

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

Start

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

Start

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

Post order Traversal : LEFT> RIGHT >ROOT

Start

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

Start

["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%

Completed

0/10

Accuracy

0%

Get Prepinsta Prime

Get all 200+ courses offered by Prepinsta

Never Miss an OffCampus Update

Get OffCampus Updates on Social Media from PrepInsta

Follow us on our Media Handles, we post out OffCampus drives on our Instagram, Telegram, Discord, Whatsdapp etc.

Get Hiring Updates
Amazon,Google,Delottie & 30+companies are hiring ! Get hiring Updates right in your inbox from PrepInsta

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.

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.

Get PrepInsta Prime Subscription

Get access to all the courses that PrepInsta offers, check the out below -

Companies

TCS, Cognizant, Delloite, Infosys, Wipro, CoCubes, KPMG, Amazone, ZS Associates, Accenture, Congnizant & other 50+ companies

Programming

Data Structures, Top 500 Codes, C, C++, Java Python & other 10+ subjects

Skills

Full Stack Web Development, Data Science, Machine Learning, AWS Cloud, & other 10+ skills and 20+ projects

Comments

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