0% found this document useful (0 votes)
877 views

Cocubes Pseudocode

Test Summary No. of Sections: 1 No. of Questions: 250 Total Duration: 60 min Section 1 - MCQ Section Summary No. of Questions: 250 Duration: 60 min Additional Instructions: None
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
877 views

Cocubes Pseudocode

Test Summary No. of Sections: 1 No. of Questions: 250 Total Duration: 60 min Section 1 - MCQ Section Summary No. of Questions: 250 Duration: 60 min Additional Instructions: None
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 144

Sample_1_Test

Test Summary
No. of Sections: 1
No. of Questions: 250
Total Duration: 60 min

Section 1 - MCQ

Section Summary
No. of Questions: 250
Duration: 60 min

Additional Instructions:
None

Q1. What will be the output of the following pseudocode?


integer n, h,m,s
set n=45000;
h=n/ 3600;
m=(n mod 3600)/60;
s=m mod 60;
print "h",":","m",":","s";
(Note mod finds the remainder alter division of one number by another . For example, the expression "5 mod 2" would evaluate to 1
because 5 evaluated by 2 leaves a quotient of 2 and a remainder of 1)

12:20:03

4:50:00

none of these options

12:30:30

Q2. What will be the output of the following pseudocode?

Start
Declare Integer x
Set x=1
While (x<20)
print x
x=x*5
End while

It prints all multiples of 5 between 1 and 10 (including both 1 and 100)

It prints all multiples of 5 between 1 and 100 (excluding both 1 and 100)

It prints all multiples of 5 between 1 and 20 (including both 1 and 20)

non of these

Q3. What will be the output of the following pseudocode?


Integer x,y,z;
Set x=2,y=4;
z = X++ + ++Y;
Print z
7

Q4. What will be the output of the following pseudocode?

integer a,b
set b=625;
for a=1 to 4
b=b/5;
a=a+b;
end for
print a

127

29

152

Q5. What is the output of the following pseudocode?


declare a,b,c and i;
set a=12 and b=6;
if ((a+b)mod 2 is equal to 0)
set c=a*b;
else
set c=a/b;
end if
for i=1 to 5
set c= c+i;
end for
print c

87

12

Q6. Integer a, b, c
set a=6, b=8, c=15
if ((b^a)<a)
b=a
End if
printf a+b+c

[Note: The bitwise exclusive OR operator(^) compares each bit of its first operands to the corresponding bit of its second operator.
The corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0].
29

35

38

48

Q7. What will be the output of the pseudocode for p=3, q=1?
Integer funn( integer p, integer q)
if(q&1>0 AND p&3>0)
return p^q
else
return funn (p,q)
end if
end function funn( )

[Note- &:bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit of the second
operand. The corresponding result bit is set to 1. Otherwise , the corresponding result bit is set to 0.
^ is the bitwise exclusive OR operator that compares each bit of its first operand to the corresponding bit of its second operand. If
one is 1 , the corresponding result bit is set to 1. Otherwise, the corresponding result it is set to 0].

-12

20

Q8. What will be the output of the following pseudocode?


Integer p, q, r
set p=1, q=2, r=0
if (p < q )
p= p << 1
if ( p > q )
r= r << 1
end if
printf p + q + r

Q9. What will be the output of the following pseudocode


Integer p, q, r
set p=1, q=4, r=1
if (q > r )
if ( q ^ q>1)
if ( r ^ r > 1)
p=1
q=1
r=2
end if
q = 111
end if
printf p + q + r
114

123

122

127

Q10. What will be the output of the following pseudocode

Integer j, m
set m = 14
integer a [ 4 ] = { 1, 13, 1, 1 }
for ( each j from 0 to 3 )
if ( a [ j ] > 1 )
continue
else
m=a[j]
end if
m=m^6
end for
print m

10

Q11. What will be the output of the following pseudocode for p = 6, q = 27

Integer funn ( integer p, integer q )


if ( p> 0 )
return p + q + funn ( p - 3, q ) + funn (p-8, q-2 )
end if
return q - 2
end function funn ( )

134

136

130

132

Q12. What will be the output of the following pseudocode


Integer p, q, r
set p= 1, q= 1, r= 3
if ( p && q>1 && r>5 )
p=p+1
end if
q=q+1
printf p + q + r
[Note- &&: Logical AND - The logical AND operator (&&) returns the boolean value true(or 1) if both operands are true and return
false]

12

17

-10

Q13. What will be the output of the following pseudocode?

Integer p, q, r
set p=1, q=1, r=1
if (0 | | 1 | | 1 )
p= p & 1
else
r=r&1
end if
print p + q + r

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit of the second
operand if both bits are 1 the corresponding result bit is set to 1. otherwise, the corresponding result bit is set to 0

| |: Logical OR - The logical OR operator (| | ) returns the boolean value True (or 1) if either or both operands is True and returns
False( or 0), Otherwise
If (X) gets executed if the value inside if( ), ie, x is not zero]

18

-1

10

Q14. What will be the output of the following pseudocode?

Integer pp, qq, rr


set pp=5, qq= 1, rr= 4
if ( pp > rr)
if (qq > rr )
rr = 1
qq = rr + 1
pp = rr + 2
end if
qq = pp+ 1
else
pp = pp + 1
end if
printf pp + qq + rr

24

16

12
15

Q15. What will be the output of the following pseudocode?


Integer a, b, c
set a =1, b= 2, c= 3
a=c
b=a
print a + b + c

13

15

Q16. What will be the output of the following pseudocode?


Integer a,b
set a= 3, b= 1
for ( each c from 2 to 5)
a= a - c
a= a + c
end for
print a+b

-1

21

Q17. What will be the output of the following pseudocode?


Integer a,b,c
set a= 0, b= 5, c=12
if (3<c)
a= 10 & c
end if
if ((c - a + b) > (b - c))
a= ( a + 6 ) + c
c=(a=a)&b
end if
print a + b + c

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit of the second
operand if both bits are 1 the corresponding result bit is set to 1. otherwise, the corresponding result bit is set to 0 ]

31

40

35

50
Q18. What will be the output of the following pseudocode?

Integer p, q, r
set p= 1, q= 1, r= 2
q=p-1
q=r-1
if (p + 2 > q -6)
if (q+2 > p- 6)
p=2
end if
q= 2
if (r> 5)
p=q
end if
end if
printf p + q + r

10

17

Q19. What will be the output of the following pseudocode?


Integer a, b, c
set a= 5, b= 11, c= 7
for ( each c from 2 to 3)
b=9+a
end for
print a + b

24

15

19

20

Q20. What will be the output of the following pseudocode?


integer pp, qq, rr
set pp= 1, qq= 2, rr= 4
if ( pp> 0 && qq> 0 && rr> 0 )
pp= 1
pp = pp >> pp
pp = pp >> pp
else
rr= 0
qq= 1
end if
print pp + qq + rr

[Note - >> - Bitwise right shift operator, it takes two numbers, right-shift the bits of the first operand the second operand decides the
number of places to shift
&& : Logical AND - The logical AND operator (&& ) returns the boolean value True (or 1) if either or both operands is True and
returns False( or 0)]

18
2

10

Q21. What will be the output of the following pseudocode?


Integer a, b, c
set a= 20, b= 5
for (each c from b to 7)
a = a-1
a= a+b
end for
a= a- b
print a + b

48

30

38

32

Q22. What will be the output of the following pseudocode?


Integer a, b, c
set a= 3, b= 4, c= 6
if (( a& 7) < b OR 5> b)
a= (b & c) & c
else
a=(8&4)+a
end if
print a + b + c

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise, the corresponding result bit is set to 0]

32

14

15

Q23. What will be the output of the following pseudocode?

Integer p, q, r
set p= 8, q= 8, r= 9
if ((r&p) + (p+q) > (r+q))
p=q
r = ( p+ 11) + q
end if
if (( p + r ) < ( q - p ))
q=r+p
p=5
end if
print p + q + r

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise, the corresponding result bit is set to 0]
43

44

39

54

Q24. What will be the output of the following pseudocode?

Integer a, b, c
set a= 7, b= 7, c= 7
if ((7- b - c) > ( c + a ))
if (( 5 - 7 ) < ( 7 + a ))
c= ( 3 & 11 ) & c
a=a
end if
c=7+c
end if
print a + b + c

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise, the corresponding result bit is set to 0]

27

21

31

Q25. What will be the output of the following pseudocode?


Integer pp, qq
set qq = 1
set pp = qq + 1
if ( pp > qq + 1)
qq = qq + 1
else
pp = qq+1
qq = pp +1
end if
print pp

-3

Q26. What will be the output of the following pseudocode?

Integer a, b, c
set a= 0, b= 2, c= 13
if (( c-7) < ( 7+c))
if (( b^c) < a)
a= b
a=a+a
end if
end if
print a = b + c

[Note: The bitwise Exclusive OR operator(^) compares each bit of its first operands to the corresponding bit of its second operator.
The corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0].

18

14

27

15

Q27. What will be the output of the following pseudocode?

Integer a, b, c
set a= 5, b = 4, c= 7
for (each c from 5 to 8)
a= 7
end for
for ( each c from 5 to 6 )
a = b ^a
a= 1 + c
end for
print a + b

[Note: The bitwise exclusive OR operator(^) compares each bit of its first operands to the corresponding bit of its second operator.
The corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0].

17

22

-9

13

Q28. What will be the output of the following pseudocode?

Integer a, b, c
set a= 1, b= 5
for (each c from 6 to 7)
a=a&c
a=a+c
end for
print a + b

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise, the corresponding result bit is set to 0]

19

18

36

14
Q29. What will be the output of the following pseudocode?
Integer p, q, r
set p= 1, q= 4, r= 2
if ( p&q)
r =p&q
end if
print r- p - q

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise, the corresponding result bit is set to 0]

11

-9

-3

Q30. What will be the output of the following pseudocode?

Integer j, m
set m = 1
integer a[4] = { 0, 1, 0, 2}
a[0] = a[ 2]
a[1] = a[0]
a[2] = a[1]
a[3] = a[2]
m= a[3]
if (m > 0)
m = m -1
end if
print m

-4

Q31. What will be the output of the following pseudocode?

Integer pp, qq, rr


set pp= 2, qq= 1
for ( each rr from 0 to 3 )
pp = pp + qq - rr
end for
if ( rr - 1 > 0 )
pp = 1
else
pp = 11
end if
print pp + qq

0
8

Q32. What will be the output of the following pseudocode?

Integer j, m
set m= 1
integer a[7] = { 1, 2, 3, 0, 5, 4, 7}
for ( each j from 2 to 5 )
if ( a[j + 1] > a[j] && a[j - 1] > a[j] )
m= m + a[j]
end if
end for
print m

[Note: && : Logical AND - The logical AND operator (&& ) returns the boolean value True (or 1) if either or both operands is True and
returns False( or 0)]

17

-2

Q33. What will be the output of the following pseudocode?


Integer pp, qq, rr
set pp= 1, qq= 50, rr= 20
if ( rr + pp < pp OR qq > 0 )
qq = 0
else
rr = 2
end if
print pp + qq + rr

18

31

28

21

Q34. What will be the output of the following pseudocode for a = 3, b = 2 ?


Integer funn ( integer a, integer b )
if ( b ^ a > (( a + 1) ^ ( b + 1 )))
a= a & b
else
b=a+1
end if
return a+ b
end function funn ( )

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise, the corresponding result bit is set to 0

^ is the bitwise exclusive OR operator(^) that compares each bit of its first operands to the corresponding bit of its second operator.
The corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0].
4

21

-1

Q35. What will be the output of the following pseudocode?


Integer p, q, r
set p= 1, q= 1,r= 1
if ( p< p^q && p^ q^ r < q)
p= q<< 1
else
q= q ^ (p & r)
end if
print p + q + r

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise, the corresponding result bit is set to 0

>> - Bitwise right shift operator, it takes two numbers, right-shift the bits of the first operand the second operand decides the
number of places to shift

&& : Logical AND - The logical AND operator (&& ) returns the boolean value True (or 1) if either or both operands is True and
returns False( or 0)]

^- The bitwise exclusive OR operator(^) compares each bit of its first operands to the corresponding bit of its second operator.
The corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0].

13

Q36. What will be the output of the following pseudocode?


Integer p, q, r
set p= 1, q= 6, r= 13
for (each r from 4 to 5 )
q= 4
end for
print p + q

19

11

Q37. What will be the output of the following pseudocode for p =1, q= 1 ?
Integer funn ( integer p, integer q )
if ( q < 1 )
return p
else
return p + funn( p, p - 1)
end if
return q
end function funn( )

-13

20

Q38. What will be the output of the following pseudocode?

Integer a, b, c
set a= 2, b= 7, c= 11
b= (a & a ) + a
b=2^a
if (( c + b) < (b - c))
c= (11 + 4) ^ b
end if
print a + b + c

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise, the corresponding result bit is set to 0
^ - The bitwise exclusive OR operator(^) compares each bit of its first operands to the corresponding bit of its second operator.
The corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0].

25

16

13

Q39. What will be the output of the following pseudocode for p= 1, q=2 ?
Integer funn( integer p, integer q)
if( q^ 2 > q^ 3)
p= q^ 2
else
q= p & 2
end if
return p ^ q
end function funn ( )

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise, the corresponding result bit is set to 0

^- is the bitwise exclusive OR operator(^) that compares each bit of its first operands to the corresponding bit of its second
operator.
The corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0].

11

2
1

Q40. What will be the output of the following pseudocode?

Integer a, b, c
set a= 8, b= 7, c=10
If ((a -b) > ( b- a))
c= 7 + b
if (( b+c) < ( a-b) )
b= 3 + a
end if
c= (4 ^ 11) & b
end if
print a + b + c

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise, the corresponding result bit is set to 0

^- is the bitwise exclusive OR operator(^) that compares each bit of its first operands to the corresponding bit of its second
operator.
The corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0].

32

22

18

25

Q41. What will be the output of the following pseudocode?

Integer a, b, c
set a= 8, b= 4, c= 15
if(( 9 + c ) & (5 ^ a) > ( b ^ a ))
b= a
a= (a + 2) + b
end if
print a + b + c

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise, the corresponding result bit is set to 0

^- is the bitwise exclusive OR operator(^) that compares each bit of its first operands to the corresponding bit of its second
operator.
The corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0].

27

37

22

32

Q42. What will be the output of the following pseudocode?

Integer a, b, c
set a= 7, b= 2, c= 8
b = ( b&b) + b
a= (5 & 11) + a
c= c
print a + b + c

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise , the corresponding result bit is set to 0]

30

20

15

22

Q43. What will be the output of the following pseudocode?

Integer a, b, c
set a= 1, b = 2 , c= 1
a= c
c= a
b= a
print a + b + c

13

15

Q44. What will be the output of the following pseudocode for p= 4, q= 4 ?


Integer funn ( integer p, integer q)
if ( p - q < 1)
return funn ( 5,1)
end if
return p & q
end function funn ( )

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise, the corresponding result bit is set to 0]

-3

Q45. What will be the output of the following pseudocode?

Integer a, b, c
set a= 2, b= 4, c= 8
a=b
if (( c & a) < b OR c < a)
c= (c ^ 6) + a
end if
print a + b + c

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise , the corresponding result bit is set to 0

^ - is the bitwise exclusive OR operator(^) compares each bit of its first operands to the corresponding bit of its second operator.
The corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0].

26

23

29

31

Q46. What will be the output of the following pseudocode?

Integer j, m
set m= 3
Integer a[4] = { 11, 11, 111, 11}
for (each j from 1 to 2)
if ( a[j - 1] + a[j] + a[j+1] )
m=m+1
end if
end for
print m

13

-2

Q47. What will be the output of the following pseudocode?


Integer p, q, r
set p= 1, q= 1, r= 1
if ( r> 0)
p= p ^ q
end if
print p + q + r

[Note: ^ The bitwise exclusive OR operator(^) compares each bit of its first operands to the corresponding bit of its second
operator.
The corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0].

-3

Q48. What will be the output of the following pseudocode?

Integer p, q, r
set p= 8, q= 6, r= 4
for ( each r from 4 to 6)
q= ( q+ 10) + q
if (( p & 4 ) < q)
q= 8 + p
else
r= 9
r= p + p
end if
end for
print p + q

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise , the corresponding result bit is set to 0]

24

26

36

22

Q49. What will be the output of the following pseudocode?

Integer m
set m=4
integer a[4] = { 1, 5, 6, 8}
a[3] =1+ a[2]
if ( m > a[3])
m= m-1
end if
print m

-8

22

Q50. What will be the output of the following pseudocode?

Integer a, b, c
set a=5, b= 11, c= 7
for ( each c from 2 to 3)
b=9+a
end for
print a + b

24

20

15

19

Q51. What will be the output of the following pseudocode?

Integer pp, qq, rr


set pp= 1, qq= 50, rr= 20
if ( rr + pp < pp OR qq > 0)
qq= 0
else
rr = 2
end if
print pp + qq + rr

18

31

28

21

Q52. What will be the output of the following pseudocode?


set p=1,q=1
Integer from ( integer p, integer q)
if( q ^ 2 > p ^ 3)
p= q ^ 2
else
q=p&2
end if
return p ^ q
end function funn ( )

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise, the corresponding result bit is set to 0

^- The bitwise exclusive OR operator(^) compares each bit of its first operands to the corresponding bit of its second operator.
The corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0].

11

Q53. What will be the output of the following pseudocode for p= 5, q=2 ?
Integer funn(integer p, integr q)
if( q& p < p^q)
p = p^3
else
q = p^2
else if
return p + q
end function funn ( )

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise , the corresponding result bit is set to 0

^ - is the bitwise exclusive OR operator(^) compares each bit of its first operands to the corresponding bit of its second operator.
The corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0].

10

16

8
Q54. What will be the output of the following pseudocode?

Integer j, m
set m = 1
integer a[4] = {4, 3, 2, 1}
a[0] = a[0] + a[1]
a[3] = a [3] + a[0]
m= a[3] + a[0]
print m

12

15

20

18

Q55. What will be the output of the following pseudocode?

Integer j, m
set m= 1
integer a[4] = { 1, 1, 1, 2}
a[2]= a[1] - a[2] + a[3]
a[3] = a[2]
m= a[3]
print m

-6

16

Q56. What will be the output of the following pseudocode?

Integer p, q, r
set p= 2,q= 0, r= 0
if (p)
r= 1
end if
if (q)
q=1
end if
print p + q + r

[Note: If (X) gets executed if the value inside if( ), ie, x is not zero]

21

3
Q57. What will be the output of the following pseudocode?

Integer a, b, c
set a= 2, b= 2
for (each c from 1 to 3)
a= (a & c) - c
end for
print a + b

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise, the corresponding result bit is set to 0]

-6

10

-1

Q58. What will be the output of the following pseudocode for a=1, b=2 ?

Integer funn( integer a, integer b)


if (b>1)
return funn (b, a -1)
else
b = b&a
return a + b
end if
end function funn ( )

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise, the corresponding result bit is set to 0]

-1

21

Q59. What will be the output of the following pseudocode?

Integer a, b, c
set a=6, b= 2, c= 7
c= 11
for (each c from 4 to 5)
a= (b^c) +c
a= (8+6) + a
a=c
end for
a= (b+b) + a
print a + b

[Note: ^ is the bitwise exclusive OR operator(^) compares each bit of its first operands to the corresponding bit of its second
operator. The corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0].

12

11
10

Q60. What will be the output of the following pseudocode?


Integer j,m
set m=1
integer a[4]= { 1, 0, 1, 2}
for (each j from 0 to 3)
if ( j> a[j])
m= m - a[j] + j
end if
end for
print m

Q61. What will be the output of the following pseudocode?

1. String str1= "aaAa", str2 = " AAa"


2. Print countVowel(upper(str1)+ lower(str2))
[Note: countVowel(string) return the number of vowels in the string. Ex-countVowels ("okay") return 2
lower(string) converts all the letters of the string to lower case,Ex-lower("Okay") would return "okay"
upper (string) converts all the letters of the string to upper case Ex-upper("Okay") would return "OKAY"]

17

Q62. What will be the output of the following pseudocode?

Integer a,b,c
set a=9, b = 11, c=9
if ((a+ b) < ( b-a))
c=12 + b
if (( a & 5) < c)
c=12
a=(12+7) + c
end if
end if
print a + b + c

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise , the corresponding result bit is set to 0]

44

34
54

55

Q63. What will be the output of the following pseudocode for p=2, q=3?

Integer funn(integer p, integer q)


if (p>q AND q>p)
p= q + q + q + q + q +q
else
q=0
end if
return p + q
end function funn ( )

10

Q64. What will be the output of the following pseudocode?


Integer a, b, c
set a=1, b=6, c=4
c= ( c + 4) + c
c = ( b + b) ^ a
c= 10+a
if (( a & b & c) < (b ^ c ^ a))
c= (b +9) & a
b= (c + 7) + b
else
b =(a & a) + c
end if
print a + b + c

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise , the corresponding result bit is set to 0

^ - The bitwise exclusive OR operator(^) compares each bit of its first operands to the corresponding bit of its second operator.
The corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0].

12

16

23

20

Q65. What will be the output of the following pseudocode?

Integer a, b, c
set a=5, b= 4, c =7
for (each c from 5 to 8)
a=3
end for
for (each c from 5 to 6)
a=b^a
a=1+c
end for
print a + b
[Note: ^ - is the bitwise exclusive OR operator(^) compares each bit of its first operands to the corresponding bit of its second
operator.
The corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0].

-11

-9

11

10

Q66. What will be the output of the following pseudocode for a= 5 , b=3 ?

Integer funn( integer a, integer b)


if( a > b)
return b + funn ( b,a)
end if
if ( a < b)
return a + b
end if
end function funn ( )

11

12

Q67. What will be the output of the following pseudocode?


Integer p, q, r
set p= 1, q= 1, r= 2
if (q ^ ( r & p)> p)
p= 0
else
p= 1
q= 3
end if
print p + q + r

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise , the corresponding result bit is set to 0

^ - is the bitwise exclusive OR operator(^) compares each bit of its first operands to the corresponding bit of its second operator.
The corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0].

Q68. What will be the output of the following pseudocode?

Integer a, b, c
set a=12, b=13
for (each c from 5 to 7)
if ( a> c)
b=10
else
Jump out of the loop
end if
a=b
end for
print a + b

22

20

30

Q69. What will be the output of the following pseudocode?

Integer j, m
set m =1
integer a[4] ={ 1, 0, 0, 0}
if (a [0] + a[3] > 0)
for (each j from 1 to 2)
if ( 1> 2)
continue
else
if (a[j] > 2)
m= 2
end if
end if
end for
end if
print m

Note: continue when a continue statement is en-counted inside a loop, control jumps to the beginning of the loop for next iteration,
skipping the execution of the statement inside the body of the loop for the current iteration

-3

15

Q70. What will be the output of the following pseudocode?


Integer p, q,r
set p=6, q= 9, r= 7
if ( q< r OR ( r& p) < ( q^ r))
r=3
q= (q + 9)+ r
end if
print p + q + r

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise, the corresponding result bit is set to 0

^ - The bitwise exclusive OR operator(^) compares each bit of its first operands to the corresponding bit of its second operator.
The corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0].
35

44

12

30

Q71. What will be the output of the following pseudocode?

Integer j, m
set m = 1
integer a[4]= { 1,11, 21, 12}
for (each j from 0 to 3)
if (j -1 > a[j] + 3)
jump out of the loop
end if
m = a[j]
end for
print m

10

12

16

18

Q72. What will be the output of the following pseudocode?

integer a, b, c
set a=1, b= 3, c= 2
if (( a&b) && (b&c) && (c&a))
a = a&b
else
b= b& a
end if
print a + b + c

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise, the corresponding result bit is set to 0

&& : Logical AND - The logical AND operator (&& ) returns the boolean value True (or 1) if either or both operands is True and
returns False( or 0)]

15

Q73. What will be the output of the following pseudocode?


1 Integer i
2 Set i = 3
3 do
4 print i + 3
5 i=i-1
5 i i 1
6 while(i not equals 0)
7 end while

666

656

555

654

Q74. What will be the output of the following pseudocode for a = 2?


1 Integer fun(Integer a)
2 Integer x, y
3 Set y = 3
4 for(each x from 0 to y-1)
5 a=a+y
6 End for
7 return a
8 End function fun()

12

11

10

Q75. Consider the following pseudocode:


integer a
set a=13
do
a=a-1
print a
continue with next iteration
print a*17
a= a-1
while(a not equals 2)
end do while
print a*a/6

Which of the following options is correct?

[Note: A do while loop is a control flow statement that executes a block of code at least once, and then repeatedly executes the
block, or not given Boolean condition at the end of the block]

It will print the reverse number from 12 to 0

It will print the reverse number from 12 to 0 except 2

It will print the reverse number from 12 to 0 except 11

It will print the reverse number from 12 to 0 except 1


Q76. What will be the output of the following pseudocode?

integer j,m
set m=1
integer a[4]={0,1,0,2}
a[1] = a[0] + a[3]
a[2] = a[1] + a[2]
a[3]= a[2]
m = a[3]
if (m)
m= m -1
else
m= m+1
end if
print m

[Note: if (x) gets executed if the value inside if(), i.e,, not zero]

Q77. What will be the output of the following pseudocode for p=22, q=4, r=2?
Integer fun(integer p, integer q, integer r)
if(p>1)
fun(p-r, q+2, r+2)
print q
end if
end function fun()

None of the mentioned option

20 14 8 0

14 12 10 8 6 4

20 18 16 14 12

Q78. What will be the output of the following pseudocode for a= 125?
integer fun1(integer a)
if(a < 4)
return a- 5
else
return fun1((a/5)-2)
end if
end function fun1()

-3
1

Q79. What will be the output of the following pseudocode?


integer p, q, r
set p=1, q=4, r=2
if (p ^q > p&q )
r= p& q
else
r=p^ q
end if
if(q> r && r>p)
p=q
end if
print p- q + r- 2

-5

-12

-4

Q80. What will be the output of the following pseudocode?


integer a, b, c, i
set a=60, b= 15
c= a/b
for(each i from 0 to c)
c= c+ b - 5
print c
while (b >= 1)
a= a-10
b= b-5
print a
end while
end for

None of the mentioned options

15 60 50 40 30 9 4 -1

14 60 50 40 9 4 -1

14 50 40 30 9 4 -1

Q81. What will be the output of the following pseudocode for x=75?
integer fun(integer x)
if((x - 35)>(x /4))
return (x/2)+5
else
return fun(fun( x/2))
end if
end function fun ( )

44

42
22

28

Q82. What will be the output of the following pseudocode?

integer a,b,c,a1,b1,c1,a2,b2,c2
set a1=2, b1=45, and c1=36
set a2=11, b2=26, and c2=30
c=c1 + c2
b=c/60
c= c mod 60
b= b+ b1 + b2
a= b/60
b= b mod 60
a= a + a1 +a2
print a:b:c

14:12:6

13:71:66

13:12:66

14:12:1

Q83. What will be the output of the following pseudocode for a=5, b=4?
integer funn(integer a, integer b)
if(b>a || a>0)
b=a
a=0
end if
if(b< a || a>0)
b= a-b
end if
return a+b
end function funn( )
[Note- ||: Logical OR operator(||) return the boolean value TRUE(or 1) if either or both operands FALSE(or 0)

17

Q84. What will be the output of the following pseudocode?


integer a, b
set a=3, b=3
a=b
if(1^1)
a=1
else
b=2
end if
print a+b

[Note: ^ is the bitwise exclusive OR operator that compares each bit of its first operands to the corresponding bit of its second
operand.If one bit is 0 and the other bit is 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set 0.
if (x) gets executed if the value inside if(), i.e,, not zero]
6

16

Q85. What will be the output of the following pseudocode?


integer a, b, c
set a=1, b=4, c=3
if (a && b)
a= a+a
end if
if(a&&b)
b=b+b
end if
print a+b+c

[Note &&: Logical AND operator (&&) returns the boolean value true (or 1) either false (or 0)
if (x) gets executed if the value inside if(), i.e,, not zero]

13

23

14

11

Q86. Consider the following pseudocode mentioned below. For how many times the loop will be taken:

integer a
set a=1
while(a<5)
a=a+2
end while
print a

Q87. What will be the output of the following pseudocode?

integer m,n
set m=9, n=6
m= m+1
n=n-1
m=m+n
if(m>n)
print m
else
print n
end if
6

15

10

Q88. For which of the following inputs, the following pseudocode will execute both the print statements?

integer a, b, c
if( a > b OR a > c)
print a
if( a+ b > c AND b< c)
print b

a=5, b=4, c=3

a=3, b=1, c=6

a=3, b=4, c=5

all of the mentioned options

Q89. What will be the output of the following pseudocode?

integer a, b,c
set a=2, b=2
if(a>2)
for (each c from 1 to 2)
a= a-b
if(0)
a= a+1
end if
a= a+b
end for
else
a= a-2
print a+b

[Note: if (x) gets executed if the value inside if(), i.e,, not zero]

11

13

Q90. What will be the output of the following pseudocode?


integer b , n
set n=1
for (each i from 1 to n)
b= i mod 4
if( b NOT EQUALS 0)
b= b-1
end if
print b
end for

[Note: MOD finds the remainder after the division of one number by another. For example, the expression "5 MOD" would
evaluate to 1 because 2 leaves a quotient of 2 and a remainder 1]

1234

none of the mentioned options

0123

0120

Q91. What will be the output of the following pseudocode?

integer n=343, r, s=0, m


set m= n
while (n is not equal to 0)
r= n mod 10
s= s*10+r
n=n/10
end while loop
print s
if (n is equal to m)
print m+1
else print m-1
end if

343 344

343 342

340 342

300 342

Q92. What will be the output of the following pseudocode?


integer a, b,c, d
set a=3, b=2, c=1, d=10
a= a<< a
b=b<<b
c=c<<c
if (c mod a EQUALS 0 || c mod b EQUALS 0)
d=d+1
end if
print d

[Note; << is left shift operator, it takes two numbers, left shift the bits of the first operand, the second operand decides the number
of plan

>>- Bitwise right shift operator, it takes two numbers, right-shift the bits of the first operand decides the number of mod finds the
remainder after the division of one number by another, For example, the expression " 5 mod 2" would evaluate to 1 because the
leaves a quotient of 2 and a remainder of 1.

||: Logical OR -the logical OR operator(||) returns the boolean value true(or 1) if either or both operands is true and returns false(or 0)
]

10

9
11

Q93. Consider the pseudocode mentioned below, what do the functions fun( ) do in general?

integer fun(integer x, integer y)


if (y EQUALS 0) return 0
return (x+ fun(x, y -1))
end function fun( )
integer run(integer a, integer b)
if (b EQUALS 0) return 1
return fun(a, run(a, b-1))
end function run( )

calculates yx

calculates x*y

calculates xy

calculates x+x*y

Q94. What will be the output of the following pseudocode?


integer a,b,c
set a=2, b=4,c=9
if((5^a^b)<(3+b+c))
c=(a+c)+b
c=a
end if
print a+b+c

[Note: ^ is the bitwise exclusive OR operator that compares each bit of its first operands to the corresponding bit of its second
operand. If one bit is 0 and the other bit is 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set 0.]

11

17

Q95. What will be the output of the following pseudocode for a=4, b=9?
integer funn(integer a, integer b)
if(b>a)
a= a+b
a= a+b
b= b+a
if(a>b)
a=a-b
return a
else
b=b-a
a=a^b
b=b^a
end if
a=1
end if
return a+b
end function funn()
[Note: ^ is the bitwise exclusive OR operator that compares each bit of its first operands to the corresponding bit of its second
operand. If one bit is 0 and the other bit is 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set 0.]

31

23

22

25

Q96. What will be the output of the following pseudocode for a=8, b=8?

integer funn(integer a, integer b)


if (a && b&& a+b > 0)
return a+ funn( a - 2, b - 2) + b
end if
return a^ b
end function funn( )

[Note: ^ is the bitwise exclusive OR operator that compares each bit of its first operands to the corresponding bit of its
second operand.If one bit is 0 and the other bit is 1, the corresponding result bit is set to 1. Otherwise the
corresponding result bit is set 0.]

40

48

39

46

Q97. What will be the output of the following pseudocode?

integer p,q,r
set p=1,q=1,r=3
p= p+((p ^ r)&q)
q=q+((p & r)^ q)
q=r+((p & r)^q)
print p+ q +r

[Note: ^ is the bitwise exclusive OR operator that compares each bit of its first operands to the corresponding bit of its
second operand.If one bit is 0 and the other bit is 1, the corresponding result bit is set to 1. Otherwise the
corresponding result bit is set 0.]

15

Q98. What will be the output of the following pseudocode for a=4, b=6?
integer funn (integer a, integer b)
if(a>2)
if(b>2)
return a+b +funn(a + 1,b - 5)
end if
end if
return a-b
end function funn( )

12

14

17

22

Q99. What will be the output of the following pseudocode?


Double b
set b = 3 & 3 && 4|| 6 | 6
print b

[||: Logical OR -the logical OR operator(||) returns the boolean value true(or 1) if either or both operands is true and
returns false(or 0) ]

1.000000

This code will produce system depents output

0.000000

2.000000

Q100. What will be the output of the following pseudocode p=20, q=25, r=30?
integer fun(integer p, integer q, integer r)
if(p>1)
fun(p-r, q,r-3)
print q
end if
end function fun

25

20

15

Q101. What will be the output of the following pseudocode?


integer i, j
set i=3, j=5
while(i>0) //line
i=i-1
while(j<6)
print "Hello"
j=J+1
Go to line
end while
end while
It will print Hello two times

It will print Hello one time

It will print Hello four times

It will print Hello three times

Q102. What will be the output of the following pseudocode?

integer p,q,r
set p=15,q=3
r=p/q
q= p mod r
p=(p+ q+ r)/5
print p, q, and r

15 3 5

405

455

15 3 3

Q103. What will be the output of the following pseudocode for a=7, b=4?
integer funn(integer a, integer b)
if (a>1 && b>1)
return a+ funn(b - a, a-b)+b
end if
if(a)
return b
end if
return 10
end function funn()

27

12

14

19

Q104. What will be the output of the following pseudocode for n=35?
integer fun1(integer n)
if (n>5)
fun1(n-5)
print n
fun1(n/5)
end if
end function fun1()

10 15 20 25 30 6 35 7

20 25 30
10 15 20 25 30

35 7

Q105. What will be the output of the following pseudocode?


integer x, y, z,j
set x=7, y=9
z= x+y
y = z mod x
x= x+y
y =x + z
for (each j from 3 to 4)
y= y-j
end for
print y

13

22

18

Q106. What will be the output of the following pseudocode for a=4, b=2?
integer funn(integer a, integer b)
if (b>a && a>0)
return funn(b - 2, a - 2)
else
return b - a
end if
return 1
end function funn ()

-4

-2

Q107. consider the pseudocode mention below.For how many times the while loop will occur?

integer a
set a=1
while(a<5)
a= a+2
end while
print a

2
5

Q108. What will be the output of the following pseudocode for p=3, q=7?
integer function funn(integer p, integer q)
integer r
set r=p
p=q
r=p
q=r
p=r
return p+q
end function funn ()

14

23

15

Q109. What will be the output of the following pseudocode for x=45?

integer fun(integer x)
if((x MOD 6) MOD 2> 0)
return x/9
else
return fun(x/9)
end if
end function fun()

[Note: MOD finds the remainder after the division of one number by another. For example, the expression "5 MOD" would
evaluate to 1 because 2 leaves a quotient of 2 and a remainder 1]

infinite loop

Q110. What will be the output of the following pseudocode for i=12?
integer fun (integer i)
if ((i/2)<(i MOD 2))
return i+1
else
return fun(fun( i -6))
end if
end function fun ()

[Note: MOD finds the remainder after the division of one number by another. For example, the expression "5 MOD" would
evaluate to 1 because 2 leaves a quotient of 2 and a remainder 1]

12
-7

13

-6

Q111. What will be the output of the following pseudocode for a=9, b = 7?

integer funn(integer a, integer b)


integer c
set c=2
b= b MOD c
a= a MOD c
return a+b
end function funn( )

17

-5

Q112. What will be the output of the following pseudocode?

char str[20]
integer s
set str ="ABCDEFGH"
s=string_length(str)
str[5]=NULL
s=strlen(str)
print s

none of the mentioned options

Q113. integer a,b,c


set a=3, b=2, c=0
while(1)
c=a+b
a=a+c
if(a>30)
jump out of the loop
else
b=b+a
end if
print b
end while

10 24
5 10

10 36

15 20

Q114. What will be the output of the following pseudocode?


integer m
set m=0
integer p[5]={1,4,5,6,7}
if (p[0] & p[1])
m=1
end if
if (p[2] & p[4])
m=p[3]
end if
print m

11

-1

15

Q115. What will be the output of the following pseudocode?

integer k, m
set m=0
integer p[3]={1,7,6}
for (each k from 0 to 2)
p[k]=p[k] + k
end for
m = p[2] & 2
print m

11

-3

Q116. What will be the output of the following pseudocode?


integer i, n=10, val=0
for (each i from 0 to n - 1)
val =i + n
val = val + n
end for
print val

11

29
62

55

Q117. What will be the output of the following pseudocode?

integer pp, qq, rr


set pp=4, qq=2
for (each rr from 1 to 3)
pp= qq + rr
if(qq > rr)
jump out of the loop
end if
end for
print pp + qq

15

Q118. What will be the output of the following pseudocode?

integer a,b,c
set a=1, b=3, c=7
a= a+b
if(a + b)
if( b + ( c^ a))
a=2
b =a

end if
end if
print a + b +c

12

22

11

Q119. For which of the following values of p, q, and r the output of the following pseudocode will be inside if?

integer p,q,r
p=p+q+r-9
q=(p+q)/2
if(p>q)
print "inside if"
else
print " inside else"
end if

None of the mentioned options


p=24,q=24,r=-15

p=12,q=7,r=-1

p=12,q=24,r=-5

Q120. What will be the output of the following pseudocode?

integer x,y,z,a
set x=2,y=1,z=5
a=(x AND y) OR (z+1)
print a

Q121. What will be the output of the following pseudocode?

integer j,m
set m=0
integer a[4]={10,11,3,2}
for (each j from m to m+3)
if (j> 0)
a[j]= a[j-1] + 2
end if
end for
m= a[0] + a[2] + a[1]
print m

52

29

41

36

Q122. What will be the output of the following pseudocode for b [] ={11, 12,18,28,45} and n=5?
integer fun(integer b[], integer n)
integer x
if(n EQUALS 1)
return b[2]
else
x=fun(b, n-2)
end if
if (x > b[ n - 2])
return x +2
else
return b[n -2]
end if
end function fun ()

20
45

28

18

Q123. what will be the output of the following pseudocode for a=6, b=1?
integer funn(integer a, integer b)
a= a + a
b= b + b
return a + b
end function funn()

16

14

12

23

Q124. What will the output of the following pseudocode for a=50
Integer fun(integer a)
Integer b
Set b=10
return a-b
End function fun( )

Non of the mentioned options

40

60

50

Q125. What will the output of the following pseudocode ?


Integer a1, p
Set a1 =8
p= a1 + 5/7 * 4
Print p * 8

64

Q126. What will the output of the following pseudocode ?


Integer x, y, z
Set x= 0, y= 1
For (each z from 0 to 2)
x= x + y + z
End for
Print x

Q127. What will the output of the following pseudocode ?


Integer p, q, r
Set p= 6, q= 3, r= 0
while(1)
r= p - q
p= p + r
if(p> 23)
Jump out of the loop
else
q= p - q
End if
print q
End while
[Note: While(1): it is an infinite loop which will run till a break of similar statement is issued
Explicitly]

3 6 12

7 7 14

6 6 12

6 6 12 18

Q128. What will the output of the following pseudocode for b=18 ?
Integer calculate(integer b)
If (b EQUALS 1)
Return 0
Else
Return 5 + calculate(b/2)
End function calculate ()

34

20

21

56

Q129. What will the output of the following pseudocode ?


integer a[3][3],k,j,sum
set sum=0
set a[3][3]={ {1,2,3}, {4,5,6}, {7,8,9} }
for (each k from 0 to 2)
for (each j from 0 to 2)
sum = sum +a[k][j]
end for
jump out of the loop
end for
print sum

it will print the sum of the elements of the second row of given 2-D array

it will print the sum of the elements of the first column of given 2-D array

it will print the sum of the elements of the second column of given 2-D array

it will print the sum of the elements of the first row of the given 2-D array

Q130. What will the output of the following pseudocode ?


integer a, b, c
set b=1, c=1
for (each a from 1 to 3)
b= b>> 1
c= c << b
end for
print b + c
[Note - >> - Bitwise right shift operator, it takes two numbers, right-shift the bits of the first operand the second operand decides the
number of places to shift
<< - Bitwise left shift operator, it takes two numbers, left shift the bits of the first operand the second operand decides the number
of places to shift]

Q131. What will be the output of the following pseudocode?

integer array1[6],p,j,q
set p=3
set array1[6]={3, 6, 10, 12, 23, 33}
for (each j from 0 to 5)
if ((array1 [j] MOD p) EQUALS 0)
p = array1[j] - (p * 3)
end if
q= p+ array1[j] - 3
end for
print q

[Note: MOD finds the remainder after the division of one number by another. For example, the expression "5 MOD" would
evaluate to 1 because 2 leaves a quotient of 2 and a remainder 1]

64

44

34
54

Q132. What will be the output of the following pseudocode?

integer a, b
set a=2,b=1
for (each a from 0 to 2)
for (each b from 0 to a)
print "laptop"
end for end for

it will print 'laptop' 2 times

it will print 'laptop' 7 times

it will print 'laptop' 6 times

it will print 'laptop' 5 times

Q133. For the following pseudocode, what should be typed in the black space?

integer Fibonacci(integer n)
if (n EQUALS 0)
return 0
else if(n EQUALS 1)
return 1
else
return (Fibonacci(n-1) + Fibonacci(........blank space...... ))
end function Fibonacci( )

n-3

n-2

n-1

Q134. What will be the output of the following pseudocode?

integer a, p
set a=5
a= a+1
a= a*2
a= a/5 + 6
print p

Q135. What will be the output of the following pseudocode?


integer p, q, r, s, t
set q= 12, r= 3
while (q > ( r- 1))
r= r * 2
s= r + q
t = (s MOD 4 ) + r
end while
if ( s > t)
print t
else
print s
end if

[Note: MOD finds the remainder after the division of one number by another. For example, the expression "5 MOD" would
evaluate to 1 because 2 leaves a quotient of 2 and a remainder 1]

22

20

24

26

Q136. What will be the output of the following pseudocode?

integer a, b
set a=1, b= 1
a= ( a ^ 1) & (1 ) + (b ^ 1) & (1)
print a+ b

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise , the corresponding result bit is set to 0

The bitwise exclusive OR operator(^) compares each bit of its first operands to the corresponding bit of its second operator.
The corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0].

none of the mentioned options

Q137. What will be the output of the following pseudocode?

integer first, second


set first= 12, second =20
first = first + second
second = first - second
first = first - second
second = second * 2
print first, second

it will swap the values of first and second and double

it will change the values of first and second as 12 and -8 respectively


it will change the values of first and second as -8 and 12 respectively

it will print the same values for first and second

Q138. What will be the output of the following pseudocode?

integer a, b, c
set b= 300, a= 5, c= 1
if( b> a)
b= a
else
a= b
end if
for ( each b from 0 to 5)
a= a+ 1
end for
print a + c

15

13

12

Q139. What will be the output of the following pseudocode?

integer a, b
set a=10, b=10
a= a & b
b= b & 10
a= a& b
b= b & 10
print a + b

[ Note- & bitwise AND - The bitwise AND operator ( & ) compares each bit of the first operand to the corresponding bit
of the second operand if both bits are 1 the corresponding result bit is set to 1. otherwise, the corresponding result bit is set to 0]

none of the mentioned options

20

Q140. What will be the output of the following pseudocode?

integer a, b, c
set b=300, a= 5, c= 1
if ( b> a)
b=a
else
a= b
end if
for (each b from 0 to 5)
a= a+ 1
end for print a + c
13

12

15

Q141. What will be the output of the following pseudocode?

integer i, j, k, m
set j=16, i=8,k=2,m=1
if( ( j^ i) mod k EQUALS 0)
m= m+ 1
else
m= m-1
end if
print m

[Note: MOD finds the remainder after the division of one number by another. For example, the expression "5 MOD" would
evaluate to 1 because 2 leaves a quotient of 2 and a remainder 1

The bitwise exclusive OR operator(^) compares each bit of its first operands to the corresponding bit of its second operator.
The corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0]

Q142. What will be the output of the following pseudocode?

integer x
set x=15
while (x EQUALS 15)
print "STUDENT"
jump out of the loop
end while

it will print "STUDENT" 16 times

it will print "STUDENT" unlimited number of times

it will print "STUDENT" only one time

it will print "STUDENT" 15 times

Q143. What will be the output of the following pseudocode?

integer a[5], k
set a[5]= {1, 2, 3, 4, 5}
for( each k from 0 to 4)
if (k mod 2 equals 0)
print a[k]* 2
else
print a[k]
end if
end for
[Note: MOD finds the remainder after the division of one number by another. For example, the expression "5 MOD" would
evaluate to 1 because 2 leaves a quotient of 2 and a remainder 1]

14385

none of the mentioned options

1 2 6 4 10

2 2 6 4 10

Q144. What will be the output of the following pseudocode?

character arr[ ]
integer size
set arr[ ]={'A', 'B', 'c', 'd', 'E', 'f'}
size= sizeof(arr)/sizeof ( arr[0] )
print size

[Note: sizeof is used to compute the size of its operand. It returns the size of a variable. It can be applied to any data type, float
type, integer.when sizeof ( ) is used with the data types, it simply returns the amount of memory allocated to that data type]

Q145. What will be the output of the following pseudocode?

integer a, b, c
set b= 1, a= 5, c= 1
if ( b < a)
b=a
end if
for(each b from 0 to ( 1 ^ 2^ 3))
b= b + 1
end for
print b

[Note: The bitwise exclusive OR operator(^) compares each bit of its first operands to the corresponding bit of its second operator.
The corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0].

Q146. What will be the output of the following pseudocode?

integer x, y, z
set x= 0, y= 1
for ( each z from 0 to 2)
x= x + y + z
end for
print x

Q147. What will be the output of the following pseudocode?

integer i
set i = 100
if (i mod (1^ 2) EQUALS 1)
i= i+9
else
i= i -11
end if
print i

[Note: MOD finds the remainder after the division of one number by another. For example, the expression "5 MOD" would
evaluate to 1 because 2 leaves a quotient of 2 and a remainder 1]

118

109

none of the mentioned options

89

Q148. What will be the output of the following pseudocode?

integer a, p
set a=5
a=a+1
a=a*2
a=a/2
p=a/ 5 + 6
print p

Q149. What will be the output of the following pseudocode?


integer a1, p1
set a1= 15
a1= a1- 1
a1= a1 * 2 + 8
a1= a1 / 2 + 9 * 5
p1 = a1 / 5 + 6
print p1
18

23

19

Q150. What will be the output of the following pseudocode?

integer j,m
set m=1
integer a[4] = { 1,1,2,2}
a[0] = a[0] + a[1] + a[2] + a[3]
a[1] = a[0] + a[1] + a[2] + a[3]
a[2] = a[0] + a[1] + a[2] + a[3]
a[3] = a[0] + a[1] + a[2] + a[3]
m = a [3]
print m

45

20

40

30

Q151. What will be the output of the following pseudocode?

integer a, b, c, d
set a= 3, b= 1
for (each c from b to b + 1)
a= a+ 1
if (1)
continue
for (each d 0 to 1)
a= a + c + d
if ( a> d)
jump out of the loop
end if
b= b + a - c + d
end for
end if
end for
print b + a

[Note - continue :when a continue statement is encountered inside a loop, control jumps to the beginning of the loop for the next
iteration ,skipping the execution of statements inside the body of the loop for the current iteration

If (X) gets executed if the value inside if( ), ie, x is not zero]

6
1

Q152. What will be the output of the following pseudocode?

integer a, b, c
set a=1, b= 6,c= 12
if ( a> b)
if (a> c)
print c+ b
else
print b
end if
else
print b + 1
end if

Q153. What will be the output of the following pseudocode?

integer a, b, c
set a= 3, b= 1
for (each c from b to a)
if ( a + b > 0)
b=a
continue
end if
a= a + b
a= a + 1
end for
print a

[Note - continue :when a continue statement is encountered inside a loop, control jumps to the beginning of the loop for the next
iteration ,skipping the execution of statements inside the body of the loop for the current iteration]

Q154. What will be the output of the following pseudocode for s= 12, k= 4, m= 2?

integer mul(integer s, integer k, integer m)


if (s + m > 1)
return ( s / m + k mod 5 + mul ( s/3, k/2, m/2))
else
return 0
end if
end function mul ()

[Note: MOD finds the remainder after the division of one number by another. For example, the expression "5 MOD" would
evaluate to 1 because 2 leaves a quotient of 2 and a remainder 1]
16

12

44

32

Q155. What will be the output of the following pseudocode?

integer a, b,c
set a=1, b=1
for (each c from 4 to 7)
a= a+1
if (a < 10)
a= a-1
continue
end if
a= a+ 2
end for
print b + a

[Note - continue :when a continue statement is encountered inside a loop, control jumps to the beginning of the loop for the next
iteration ,skipping the execution
of statements inside the body of the loop for the current iteration]

Q156. What will be the output of the following pseudocode?

integer a, b, c
set a=3, b=2
if (b-1)
for (each c from 1 to 3)
a= a-1
end for
for(each c from 1 to 3)
a= a + b
end for
end if
print a+ b

[ Note: If (X) gets executed if the value inside if( ), ie, x is not zero]

Q157. What will be the output of the following pseudocode?

integer a1, a2, p


set a1= 16, a2= 234
p= (a1 + a2) AND (a1) OR (a2)
if ( p not equqls 0)
print p + p
else
print p
end if

[Note-:&& : Logical AND - The logical AND operator (&& ) returns the boolean value True (or 1) if either or both operands is True and
returns False( or 0)]

| | : Logical OR - The logical OR operator (| | ) returns the boolean value True (or 1) if either or both operands is True and returns
False( or 0), Otherwise ]

Q158. What will be the output of the following pseudocode?

integer a, b, j
set a=10, b= 18
for (i=6 to a-1) increase i by
b= ((b*2)/ 2) + 3
print b
end for

21 24 27

21 24 27 30 33

18 21 24 27

21 24 27 30

Q159. What will be the output of the following pseudocode?

integer a, b, c
set a=13, b= 9, c= 6
if (a< b)
if (a < c)
print a
else
print c
end if
else if (b < c)
print b
else
print c
end if

69

6
13

Q160. What will be the output of the following pseudocode?

integer i, a, j
set i=6, a=23
j= i + a && i / a && a/ i + i
if (j)
print j
else
print j + j
end if

[&& : Logical AND - The logical AND operator (&& ) returns the boolean value True (or 1) if either or both operands is True and
returns False( or 0)
If (X) gets executed if the value inside if( ), ie, x is not zero]

20

Q161. What will be the output of the following pseudocode?

integer a, b , a, d
set a=3, b= 1, c=1
for (each d from 1 to 3)
a= a-1
if(d> 2)
a= a- b
b=a
if (d < 2)
jump out of the loop
end if
a= a + 1
end for
print a + c

-5

Q162. What will be the output of the following pseudocode?

integer a, b
for (each a from 1 to 2)
b= 17
print b + a - a * a
end for
print a + 1

17 17 16
17 15 4

123

17 4 15

Q163. What will be the output of the following pseudocode?

integer k
set k=6/7 + 3 - 3
if ( k < = 0)
if ( k equals 0)
print "test1"
else
print " test2"
end if
else
print "test3"
end if
print " test completed"

test3 test completed

test2 test completed

test completed

test1 test completed

Q164. What will be the output of the following pseudocode?

integer j, m
set m=1
integer a[4]= {0, 1,0,2}
a[0] = a[0] - a[2] + a[3]
a[1] = a[0] -a[3]
a[2]= a[1] - a[2]
a[3] = a[2]
m = a[3]
print m

Q165. What will be the output of the following pseudocode?

integer n
set n=15
while( n <=15)
n= n + 6/3
print " biography"
continue with next iteration
end while
it will print biography 13 times

it will print biography 15 times

it will print biography 1 time

it will print biography 14 times

Q166. What will be the output of the following pseudocode for p= 8?


integer combine(integer p)
if (p < = 17)
combine(combine(p * 2))
end if
return p + 3
end function combine ()

13

34

11

12

Q167. What will be the output of the following pseudocode for a= 22 ?

integer compact(integer a)
if( a <= 45)
compact( compact (compact (a * 5 + 1)))
end if
return a*2
end function compact ()

22

45

56

44

Q168. What will be the output of the following pseudocode for a=100?

integer f5( integer a)


if ( a mod 2)
return a++
else
return f5(f5 ( a- 1))
end if
end function f5()

[Note: MOD finds the remainder after the division of one number by another. For example, the expression "5 MOD" would
evaluate to 1 because 2 leaves a quotient of 2 and a remainder 1]
99

98

101

87

Q169. What will be the output of the following pseudocode if a = 2 b = 7?

integer funn( integer a, integer b)


if (a > -2)
if(b + 1)
return 2
end if
return a
end if
return b
end function funn ( )

[Note:If (X) gets executed if the value inside


if( ), ie, x is not zero]

11

Q170. What will be the output of the following pseudocode?

character a[20], b[20]


set a[20] = "Alpital"
integer j, k
set j= 0, k=0
while (a[j] NOT EQUALS null character)
if (j mod 2 EQUALS 0)
b[k]= a[j]
else
b[k]= ' '
end if
k= k + 1
j= j + 1
end while
set k= 0
while (b [k] NOT EQUALS null character)
print b [k ]
k= k + 1
end while

[Note: MOD finds the remainder after the division of one number by another. For example, the expression "5 MOD" would
evaluate to 1 because 2 leaves a quotient of 2 and a remainder 1]

talp

lIa

Atpl
Aptl

Q171. What will be the output of the following pseudocode for a1= 3 and b1= 4?

integer fun(integer a1, integer b1)


if (a1 EQUALS 0)
return b1 + 6
else if(a1 EQUALS 1)
return b1
else
return fun ( a1 - 1, a1 + b1 + 5 ) + fun ( a1 - 1, a1 + b1)
end if
end function fun ( )

54

56

77

57

Q172. What will be the output of the following pseudocode?

integer p
set p = 1
while( p + 2 <= 4)
print p
p= p+1
jump out of the loop
end while

Q173. What will be the output of the following pseudocode?

Integer x
Set x= 3
do
X= x-1
Print x * 4
Continue with next iteration
Print x * 7
X= x-1
While ( x not equals 2)
End do while
Print x * x/6

[Note:- A do-while is a control flow statement that executes a block of code at least once and then repeatedly executes the block ]

78
80

96

70

Q174. What will be the output of the following pseudocode?

Integer j, m
Set m= 1
Integer a[4] = { 1,1,2,2}
a[0] = a [0] + a [1]
a[1] = a [1] + a [2]
a[2] = a [2] + a [3]
a[3] = a [3] + a [0]
m= a[3]
Print m

Q175. What will be the output of the following pseudocode?

Integer f, k, j
Set f= 9, k= 55
j= f + k / 8
if( j + 1 >= 8)
f=f+1
Else
K=k+1
End if
Print f + k

65

67

78

66

Q176. 1. What will be the output of the following pseudocode?

Integer k, a, p
Set k = 5, a =234
P= k + a && k / a || a/ k + k
If(k)
Print “it is working”
Else
Print “it is not working”
End if

[Note:-&& : Logical AND - The logical AND operator (&& ) returns the boolean value True (or 1) if either or both operands is True and
returns False( or 0)
| | : Logical OR - The logical OR operator (| | ) returns the boolean value True (or 1) if either or both operands is True and returns
False( or 0), Otherwise]

No output

It is working

It is not working

Q177. What will be the output of the following pseudocode?


Integer a, b,c
Set a=3, b= -2
If(b - 1 > b)
For (each c from 1 to 2)
a= a- 1
If( c > 0)
Jump out of the loop
End if
Continue
a= a + 1
a= a - 3
a= a + 2
End for
End if
Print a + b

[Note - continue :when a continue statement is encountered inside a loop, control jumps to the beginning of the loop for the next
iteration ,skipping the execution
of statements inside the body of the loop for the current iteration]

Q178. What will be the output of the following pseudocode?


Integer i, a, j
Set i= 6, a= 23
j= i+ a && I / a && a / i + i
If(j)
Print j
Else
Print j * j
End if

[ Note:-&& : Logical AND - The logical AND operator (&& ) returns the boolean value True (or 1) if either or both operands is True and
returns False( or 0)
If (X) gets executed if the value inside if( ), ie, x is not zero]

20

Q179. What will be the output of the following pseudocode?


integer a, b, c
set a= -3, b = -2
if( b - 2 < b)
for (each c from 1 - 1 to 2 - 1)
a= a + 1
end for
end if
print a +b

-4

-3

Q180. What will be the output of the following pseudocode?

Integer i, j, k
sett i= 1, 2, 3
set j= 1, 2, 3
set k=1, 2, 3
print i, j, k

1,2,3

1,1,1

123,123,123

3,3,3

Q181. What will be the output of the following pseudocode?

char arr [3][2]


set arr[3][2] = { { 12, 21},{13, 54},{ 52, 63} }
integer x, k, j
set x=1
for (each k from 0 to 3)
for (each j from value equal to k to less than equal to the value of k)
x = x + arr [k] [j]
end for
continue with next iteration end for
print x

45

67

65

78

Q182. What will be the output of the following pseudocode?

integer a, b
set a=5, b= 8
do
print b/ a
while (a/ b)
end do while

1.6

Q183. For which of the following options, the pseudocode will print the square of variables ' a'?

integer a
if( a mod 2 not equals 0)
if( a > 12)
print a * a
end if
end if

[Note: MOD finds the remainder after the division of one number by another. For example, the expression "5 MOD" would
evaluate to 1 because 2 leaves a quotient of 2 and a remainder 1]

when the value of variable ' a' is odd

when the value of a= 13

none of the mentioned options

when the value of variable 'a' is even

Q184. What will be the output of the following pseudocode?

integer a, b, c, d
set a= 3, b= 1
for (each d from 1 to 3)
for (each c from 1 to 2)
if( c < d + 1)
a= a- b
else
a= a+ b
end if
end for
end for
print a

-2

Q185. What will be the output of the following pseudocode?

integer k, p, i
set k= 2, p= 6
int i= k / p + 3 * k/ p
if (i)
print " you are promoted "
else if ( i not equals 0)
print " you are not promoted"
else
print " you better try next time "
end if

[ Note:-If (X) gets executed if the value inside if( ), ie, x is not zero]

you are promoted

you better try next time

you are not promoted

Q186. What will be the output of the following pseudocode?

integer a, b, c
set a=11, b= 21
for(each c from 16 to 17)
if ( c-10 > 8)
if (1 && 1)
a= a + c
end if
a= a + 1
else
a= 0
end if
end for
print b + a

[Note:- && : Logical AND - The logical AND operator (&& ) returns the boolean value True (or 1) if either or both operands is True and
returns False( or 0)
If (X) gets executed if the value inside if( ), ie, x is not zero]

11

14

32
50

Q187. What will be the output of the following pseudocode?

integer a, b
set b= 2
set a= b + 3
if (a && b - a && 1)
a=a +1
end if
print a

[Note:-&& : Logical AND - The logical AND operator (&& ) returns the boolean value True (or 1) if either or both operands is True and
returns False( or 0)]

Q188. What will be the output of the following pseudocode?

integer n, c
set n= 128, c= 4
while( n NOT EQUALS 0)
n= n / 10
c=c-1
end while
print c

-1

Q189. What will be the output of the following pseudocode?

integer a[5]
set a[5]= { 1,2,3,4}
integer m, j
set m= 1
for ( each j from 0 to 3)
m= m + a[j] + a[ j] + 6
end for
print m

43

45

23
46

Q190. How many times the following pseudocodes will print hello?

integer k, p, j
set k= 1, p= 4
int j= p + k / 2
if ( j equals p)
print "hello"
end if
j= p + k / 5
if ( j not equals p)
print " hello "
end if
print " hello "

three times

one times

two times

will not print hello at all

Q191. What will be the output of the following pseudocode?

integer k, p
set k= 56
p = k + 8 - 78 / 8 * 4/7 - 5/ 2
if (p )
print "hello "
else
print " bye"
end if

[Note: If (X) gets executed if the value inside if( ), ie, x is not zero]

none of these mentioned options

hello

hello bye

bye

Q192. What will be the output of the following pseudocode?

integer a, b, c
set a= 1, b= 2
for (each c from 216 to 217)
if( c - 200 > 100)
if( 1 && 1)
a= a + c
end if
a= a+ c
else
a=0
end if
end for
print b + a

[Note:-&& : Logical AND - The logical AND operator (&& ) returns the boolean value True (or 1) if either or both operands is True and
returns False( or 0)]
8

Q193. What will be the output of the following pseudocode?

integer a, b, c, d
set d= 6
for( each a from 1 to 2)
for(each b from a to 2)
for (each c from b to 2)
print d
end for
end for
end for

666666

666

6666

Q194. What will be the output of the following pseudocode?

integer a, b, c
set a= 108, b= 2, c= 3
if (( a MOD 9) EQUALS 0)
b= b + (a MOD 2)
print b
else
c= c + ( a MOD 7)
print c
end if

[Note: MOD finds the remainder after the division of one number by another. For example, the expression "5 MOD" would
evaluate to 1 because 2 leaves a quotient of 2 and a remainder 1]

Q195. What will be the output of the following pseudocode for a= 6?

integer fun (integer a)


if (a EQUALS 0)
return a+ 9
else
return fun(a-1)
end function fun()
6

Q196. What will be the output of the following pseudocode?

integer i
set i=45
if( i mod 2 EQUALS 0 OR i mod 2 AND i)
print i mod 2
else
print i
end if

[Note: MOD finds the remainder after the division of one number by another. For example, the expression "5 MOD" would
evaluate to 1 because 2 leaves a quotient of 2 and a remainder 1
| | : Logical OR - The logical OR operator (| | ) returns the boolean value True (or 1) if either or both operands is True and returns
False( or 0), Otherwise]

45

Q197. Consider the following algorithm:

integer fun (Node *{p)


integer x= MIN_INT
while(p not equals NULL)
if (p->data < x)
return 0
else
x= p -> data
p -> next
end if
end loop
return x
end fun

p is a pointer to the first node of the linked list, Which of the following operations is performed by the function fun?

function fun detects a loop in the linked list, it return 1 when a loop is found
and 0 when no loop is found

None of the mentioned options

Functions fun finds the largest element of the linked list

Function fun checks whether a linked lists is sorted or not. It returns 0 when
the list is not sorted and 1 when it is sorted
Q198. What will be the output of the following pseudocode?

integer a
string str1
set str1= " momo"
for (each a from 1 to 2)
str1= str1 + " mm"
end for
print (stringLength(str1))

Q199. What will be the output of the following pseudocode?


integer a
set a= 10
while ( a NOT EQUALS a/2)
print "engineering"
a= a-1
if( a EQUALS 3)
print " engineering"
end if
jump out of the loop
print " engineering"
end while
if (a EQUALS 2)
print " 23"
else
print "engineering"
end if

it will print engineering 3 times

it will print engineering 2 times

it will print engineering 4 times

it will print 23

Q200. How many times the following pseudocode will print "btech"

integer a, b
for(each a from 0 to 3)
for(each b from 0 to a)
print "btech"
end for
end for

3 times

9 times

10 times
11 times

Q201. What will be the output of the following pseudocode for a= 3 and b= 4?

integer foo( integer a, integer b)


if( a EQUALS 0)
return b
else if ( a EQUALS 1)
return b + 1
else
return foo(a - 1, a + b +5)
end if
end function foo()

20

10

Q202. What will be the output of the following pseudocode for a= 2?

integer fun( integer a)


integer p=1
if( a > 0)
return p + fun( a- 1)
else
p= p + 1
return a + p
end if
end function fun()

Q203. What will be the output of the following pseudocode?

integer a[10]
set a[10]= { 1,2,3,4,5,6,7,8,9}
for(each i from 1 to 4)
if (a[ i / 2])
print a[ i * 2]
else
print a[ i + 2]
end if
end for

2468

12345

2680
3579

Q204. What will be the output of the following pseudocode?

integer a,b
set a= 0
a= a^ 1
a= a^ 2
a= a^ 3
print a

[Note: The bitwise exclusive OR operator(^) compares each bit of its first operands to the corresponding bit of its second operator.
The corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0].

Q205. What will be the output of the following pseudocode?

integer h
set h= 42
do
print h
h ++
if (h > 45)
jump out of the loop
while()
end do while

42 43 44 45

43

42

42 44 45 46

Q206. What will be the following pseudocode?


character p[20], b[20
set p[20]= "Respect Your elders"
integer k
set k= 0
while (p[k] not equals null character AND p[k] not equals space)
b[k]= p[k]
k= k + 1
end while
set k =0
while( b[k] not equals null character)
print b[k]
k= k + 1
end while

[Not:&& : Logical AND - The logical AND operator (&& ) returns the boolean value True (or 1) if either or both operands is True and
returns False( or 0)]
Respect elders

elders

Respect

Q207. What will be the output of the following pseudocode?

integer k, m
set k= 1, m= 9
if(k + 8/m)
print m
m= m + 1
if(k* 8 / m)
print k
k= k- 1
for(each k from m to 8) decrease k by 1 in each iteration
print k
end for

9 10 9 9

9 10 8 9

9 10 9 8

9 10 9 10

Q208. What will be the output of the following pseudocode?

integer s
set s=78
while(s EQUALS 78)
if ( s< 89)
s= s + 1
continue with next iteration
print "welcome"
else
jump out of the loop
end if
end while

None of the mentioned options

It will print "welcome" only one time

It will print nothing

It will print "welcome" 78 times

Q209. What will be the output of the following pseudocode for a=3?
integer fun(integer a)
integer arr[]={10,7,2,6,1,2,3}
integer p, sum =0
for(each p from 0 to a-1)
sum = sum + arr [a]
end for
return sum
end function fun()

20

18

21

15

Q210. What will be the output of the following pseudocode?

integer arr[]= {10, 20,30,40,5}


integer a, s
set s=0
set a= arr[ 1] +arr [2]
print a

50

40

25

Q211. What will be the output of the following pseudocode?

integer a, b,c
set b=3, a= 5, c=1
if( b < a )
b= a
end if
for(each b from 0 to (1^2^3))
b= b + 1
end for
print b

In python ^ is used to find the power of a number.

Q212. What will be the output of the following pseudocode?

integer a, b
set a=15, b= 7
a= a mod (a-3)
b= b mod (b-3)
a= a mod 1
b= b mod 1
print a + b
0

15

Q213. What will be the output of the following pseudocode for a=2?

integer fun(integer a)
if(a>0)
return a+ fun(a-1)
else
return 0
end if

Q214. What will be the output of the following pseudocode?

integer a, b,c
set b=5, a=2, c=2
if(a)
a=a-1
a=c
else
c=c+1
end if
if(a-1)
c=c+1
else
c=c-1
end if
print a+b+c

15

20

10

11

Q215. What will be the output of the following pseudocode f(x) x =777
1 Integer fun(Integer x)
2 if (x > 12)
3 fun (x / 9)
4 print x
5 else
6 for (each i from 1 to 3)
7 x=x+i
8 print x
9 end for
10 end if
10 end if
11 end Function fun( )

11 13 14 85 777

12 14 15 86 777

10 12 13 86 777

10 12 13 85 777

Q216. What will be the output of the following pseudocode for x = 4 and y = 2
1 Integer fun (int x, int y)
2 if (x > 1)
3 fun (x - 2, y + 2)
4 end if
5 print y
6 End Function fun( )

456

975

765

None of the mentioned options

Q217. What will be the output of the following pseudocode for x = 45?
[Note: mod finds the reminder after the division of one number by another , For example , the expression "5 mod 2" would evaluate
to 1 because 5 divided by 2 leaves a quotient of 2 and reminder of 1]

1 Integer fun (Integer x)


2 if (( x MOD 6) MOD 2 >0)
3 return x / 9
4 else
5 return fun (x / 9)
6 end if
7 end function fun ( )

Infinite loop

Q218. What will be the output of the following pseudocode for x = 343?
[Note: mod finds the reminder after the division of one number by another. for example , the expression "5 mod 2" would evaluate to
1 because 5 divided by leaves a quotient of 2 and a reminder of 1]

1 Integer fun (Integer x)


2 if (( MOD 10) EQUALS ( / 10))
2 if ((x MOD 10) EQUALS (x / 10))
3 return (x / 7)
4 else
5 return fun (fun (x/7))
6 end if
7 end function fun( )

49

Q219. What will be the output of the following pseudocode for x = 23 and y = 222
Note: 1. ' << ' is Left shift operator
2. '&' is bitwise AND , the output of the bitwise AND is 1 if the corresponding bits of has represents is 1. It can be the result of the
corresponding bit is evaluated to 0.
3. '^' is bitwise XOR , the result of the bitwise XOR operator is 1 if the corresponding bits of the operator.

1 Integer fun1 (Integer x, Integer y)


2 while (y NOT equals 0)
3 Integer c = x & y
4 x=x^y
5 y = c << 1
6 end while
7 return x
8 End function fun1()

245

22

2223

1022

Q220. What will be the output of the following pseudocode?


Note: The logical AND operator (&&) returns the Boolean value TRUE or and returns FALSE otherwise.
1 Integer x, y, 1, z
2 Set x = 11 , y = 10
3 y=y-5
4 z=y=3
5 1 = x AND z
6 Print z, 1

40

31
61

20

Q221. What will be the output of the following pseudocode for x = 108, y = 3 ?
1 Integer fun (Integer x, Integer y)
2 if (x > 1)
3 fun (x/y, y+3)
4 Print y
5 enf if
6 end function fun ()

12 9 6

12 9 6 3

0 6 36 108

6 12

Q222. What will be the output of the following pseudocode?


1. String str1 = "what" , str2 = "e"
2. Print subString (lower (str1+ upper(str2) + str 2 + str2 + str2) 1, 4)
Note: subString (string , integer-1 , integer-2) returns the substring from index equals integer-1 to index equals to integr-2 , e.g
subString ("OkaY" , 0,2) would return "Ok" lower(string) converts all the letters of the string to lower case , e.g lower("OkaY) would
return "okay" upper(string) converts all the letters of the string to upper case , e.g upper("OkaY") would return "OKAY".

hta

ath

hat

tah

Q223. What will be the output of the following pseudoode?


Note: >> - Bitwise right shift operator , it takes two number , right shift the bits of the first operand , the second operand decides the
number of place to shift.
1 Integer v, a, r
2 Set v = 5 , a = 64
3 r = a>>v
4 r=a-r
5 Print r

64

66
62

68

Q224. What will be the output of the following pseudocode?


1 char str[20]
2 Integer s
3 Set str = " ABCDEFGH "
4 s = string_length(str)
5 str[5] = NULL
6 s = strlen(str)
7 print s

None of the mentioned options

Q225. What will be the output of the following pseudocode?


Note: &&-: Logical AND - The logical AND operator (&&) returns the Boolean value true(or 1) if both operands are true and return
false (or 0 ) otherwise.

1 Integer p, q, r
2 Set p = 0, q = 3, r = 14
3 if (1< p && (q+p) >(p+q))
4 r=q+r
5 End if
6 print p + q + r

17

19

28

14

Q226. What will be the oyutput of the following pseudocode?


1. String str1 = "Start" , str2= "trast"
2. Print reverse(str2 + str1)
Note: reverse(string) reverses the string , e.g . reverse ('okaY') returns 'Yako"

tratStsart

tratrat
tratstartt

tratStart

Q227. What will be the output of the following pseudocode?


1 Integer i
2 Set i = 0
3 Start : i= i + 12
4 Print i
5 if (i < 60)
6 goto Start
7 else
8 Print i + 1
9 end if

0 12 0 12 13

12 24 36 48 60 61

0 12 24 25

12 24 36 48 61

Q228. What will be the output of the following pseudocode?


1 Integer p , q
2 Set q = 280,p=0
3 for (each p from 1 to 4)
4 q = q / 10
5 p=p+q+2
6 enf for
7 Print p

32

288

12

38

Q229. What will be the output of the following pseudocode?


Note: mod finds the reminder after the division of one number by another. For mod to 1 because 5 divided by 2 leaves a quotient of
2 and a reminder of 1.
1 Integer p, q, r
2 Set q = 13
3 for (each p from 1 to 4)
4 r = q mod p
5 p=p+5
6 q=p+r
7 end for
8 r=q/5
9 Print q , r
13

61

72

64

Q230. What will be the output of the following pseudocode for the input pqr?
Note: Here NULL typically means the end of the string.
1 fun(char a )
2 if (a[0] EQUALS NULL)
3 Return
4 end if
5 fun(a + 1)
6 fun(a + 1)
7 Print (a[0])
8 end function fun

rrqrrqp

ppqqrr

rqppqr

None of the mentioned options.

Q231. What will be the output of the following pseudocode?


Note-&: bitwise AND - The bitwise AND operator (&) compares each bit of the first operand to the corresponding bit of the second
operand. If both bits are 1 , the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0.
^ is the bitwise exclusive OR operator that compares each bit of its first operand to the corresponding bit of its second operand. If
one bit is 0 and the other bit is 1 , the corresponding result bit is set to 1. Otherwise , the corresponding result bit is set to 0.
1 Integer pp, qq, rr
2 Set pp = 7, qq = 7, rr
3 for (each rr from 3 to 5)
4 pp = qq + pp
5 if ((3-rr-qq) > (qq-pp))
6 pp= 3 + rr
7 pp= (qq^pp)& pp
8 Enf if
9 Enf for
10 Print pp + qq

24

16

12

14

Q232. What will be the output of the following pseudocode?


Note - & : bitwise AND - The bitwise AND operator (&) compares each bit of the first operand to the corresponding bit of the second
operand. If both bits are 1, the corresponding result bit is set to 1. Otherwise the corresponding result bit is set to 0.
1 Integer pp, qq, rr
2 Set pp = 2, qq= 5, rr = 6
3 qq = (6&4) + rr
4 qq = (10&6) + pp
4 qq (10&6) + pp
5 pp = 9 + rr
6 Print pp + qq + rr

41

25

30

Q233. What will be the output of the following pseudocode?


Note-&: bitwise AND - The bitwise AND operator (&) compares each bit of the first operand to the corresponding bit of the second
operand. If both bits are 1 , the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0.
^ is the bitwise exclusive OR operator that compares each bit of its first operand to the corresponding bit of its second operand. If
one bit is 0 and the other bit is 1 , the corresponding result bit is set to 1. Otherwise , the corresponding result bit is set to 0.
1 Integer pp, qq, rr
2 Set pp=1, qq=5, rr=10
3 rr=(9+1)&&pp
4 rr=(rr&3)^rr
5 if((rr^qq)+(qq^pp)>(rr+qq&pp))
6 pp= (qq+rr)+rr
7 qq= 7&qq
8 End if
9 Print pp+qq+rr

14

29

10

Q234. What will be the output of the following pseudocode?


Note: Continue; When a continue statement is encountered inside a loop , control jumps to the beggining of the loop for the next
iteration, skipping the execution of statements inside the body of the loop for the current iteration.
bitwise AND - The bitwise AND operator (&) compares each bit of the first operand to the corresponding bit of the second operand.
If both bits are 1, the corresponding result bit is set to 1. Otherwise the corresponding result bit is set to 0.
1 Integer pp, qq, rr
2 Set pp=1, qq=4, rr=8
3 for (each rr from 3 to 6)
4 qq= rr&pp
5 if((rr+qq)>(pp-rr))
6 continue
7 Else
8 rr=(9+4)+pp
9 pp= qq+rr
10 End if
11 End for
12 Print pp+qq

1
15

-1

Q235. What will the output of the following pseudocode?


1 Integr 1, k, m, a[5]
2 Set 1= 5
3 Set a[5] = { 3, 4, 6, 16, 7}
4 for (each k from 0 to 4)
5 if(1< a[k])
6 1= a[k]
7 end if
8 m= 1 + a[k]
9 end for
10 Print m

23

17

14

None of the mentioned options

Q236. The following pseudocode can be used for:


1. Let LB be the lower bound and UB be the upper bound of a linear array a.
2. [Initialize counter] set k at lower bound LB.
3. Repeat for k = LB to UB
4. print a[k]
5. [End of for loop]
6. Exit

traversing an array

inserting an element in an array

sorting an array

deleting an element from an array

Q237. Which of the statements given in the options is correct regarding the following pseudocode?
1 if(x > y):
2 if(z > y):
3 if(z == x):
4 print ("two");
5 else:
6 print ("one");
7 else:
8 print ("three");
9 else:
10 print ("four");

None of the mentioned option is correct.

It will print one if x=5, y =10, z=9


It will print three If x=9, y=8, z=10

It will print three If x=9, y=8, z=6

Q238. What will be the output of the following pseudocode?


1 Integer b=7, c=1, i, j
2 for (j=2 to 3)
3 for (i = 1 to J)
4 c = c*2
5 end loop
6 end loop
7 b= b+c
8 Print b , c

36 43

23 16

71 64

39 32

Q239. Which one of the following gets generated by the given pseudocode for input n=5?
1 function(input n)
2 {
3 if (n < 2)
4 return n;
5 else return function (n-1) + function(n-2);
6 }
7
8

Q240. What will be the output of the following pseudocode?


Note: mod finds the reminder after the division of one number by another . for example, the expression because 5 divided by
2 leaves a quotient of 2 and a reminder of 1.
1 Integer p[10] = { 12, 16, 24, 2, 18, 20}
2 Integer a, b, c, d, e
3 Set b = 0, e = 2
4 for ( c from 1 to 11) and Increment c by 2 for each iteration
5 b = b +p[c+1]
6 end for
7 d = (b+e) MOD 2
8 Print d
33

14

Q241. What will be the output of the following pseudocode?


1 Integer p, q, r, s, t
2 Set q = 81, r = 10
3 while (q>r)
4 p=q+r
5 s = p / 10
6 t=s*s
7 q=q/3
8 end while
9 if (t > s)
10 Print s
11 else
12 Print t
13 end if

12

Q242. What will be the output of the following pseudocode?


1. Integer a, b, c, d, i
2. Set a = 65, b= 0, c = 6, d= 0 , i= 1
3. while (a>c)
4. b = (c + d) *2
5. d = c << i
6. while (b < 20)
7. Print d
8. d=d+2
9. b=b+2
10. end while
11. c = c + 10
12. end while
13. Print b
Note: << is the left shift operator , it takes two number , left sides the bits of the first operand, the second operand decides the
number places to shift.

12 12 16 18 112

0 2 4 6 112

None of the mentioned options.

12 14 16 18 296

Q243. What will be the output of the following pseudocode for n = 243?
Note: mod finds the reminder after the divisions of one number by another. For example , the expression " 5 mod 2" would evaluate
to 1 because 5 divided by 2 leaves a quotient of 2 and a reminder of 1.
1 Integer abc (int n)
2 Integer a, b
3 if (n > 0)
4 a = n mod 10
5 b=b+a
6 abc = (n / 10)
7 else
8 return b
9 End abc ()

342

Q244. What will be the output of the following pseudocode ?


1. Integer a, b, v, c
2. Set a = 7, b = 12, v = 70
3. while ( v> 5)
4. a = a - v
5. c = ( a + b ) mod 10
6. while (c > 7)
7. b=b+c
8. end while
9. v=v/2
10. end while
11. Print b, c

12 1

12 - 1

14 - 2

Infinite loop

Q245. Consider the following pseudocode:

1. Integer fun ( Integer a[ ], Integer n)


2. Integer x
3. if (n EQUALS 1)
4. return a[0]
5. else
6. x = fun (a, n-1)
7. end if
8. if (x > a[n-1])
9. return x
10. else
11. return a [n-1]
12. End function fun ()
What will be the output of the given code for the following input?
[ Input : a[ ] = { 12, 10, 30, 50, 100}, n = 5]

120

100

80
56

Q246. What will be the output of the following pseudocod


1 Integer p , q , r , s
2 Set p = 15, q = 0, r = 60, s = 0
3 while ((r MOD p ) EQUALS 0)
4 s = ( s+2) * 2
5 q=q+p
6 while (s < 50 )
7 Print s
8 q=q-1
9 s=s+q
10 end while
11 p = p -3
12 end while
13 print q

4 28 60 23

19 27 54 63 23

4 18 31 43 23

4 18 31 43 26

Q247. What will be the output of the following pseudocode?


Note-&: bitwise AND - The bitwise AND operator (&) compares each bit of the first operand to the corresponding bit of the second
operand. If both bits are 1 , the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0.
1 Integer a,b, c
2 Set a = 3, b = 4, c = 5
3 if ((b - c + a)< ( a - b ))
4 a=(a+9)&a
5 b = ( c & c) + a
6 if (( a + 6) >(c-a))
7 c = ( c +c) + c
8 End if
9 c=b+a
10 c=8+a
11 End if
12 Print a + b+c

12

22

16

Q248. What will be the output of the following pseudocode?


1 Integer a , b, c
2 Set a=1, b=4, c=8
3 if(b>c OR (a+b)<(b-a))
4 a = (7+10) + a
5 b= (8+5) + a
6 End if
7 Print a + b + c
13

26

17

Q249. What will be the output of the following pseudocode?


Note- ^ is the bitwise exclusive OR operator that compares each bit of its first operand to the corresponding bit of its second
operand. If one bit is 0 and the other bit is 1 , the corresponding result bit is set to 1. Otherwise , the corresponding result bit is set
to 0.
1 Integer j, m
2 Set m = 2
3 Integer a[4] = { 2,1,1,2 }
4 m = m^a[2]
5 if (a[1]>1)
6 m = m^1
7 Else
8 m = m^2
9 End if
10 Print m

12

-1

Q250. What will be the output of the following pseudocode?


Note: ^ is the bitwise exclusive OR operator that compares each bit of its first operand to the corresponding bit of its second
operand. If one bit is 0 and the other bit is 1 , the corresponding result bit is set to 1. Otherwise , the corresponding result bit is set
to 0.
1 Integer p, q, r
2 Set p= 5, q = 5, r = 10
3 For ( each r from 4 to 8)
4 q = (5^7) + p
5 if ((3^4) <r)
6 jump out of the loop
7 Else
8 p= p+r
9 End if
10 End for
11 Print p+q

50

64

57

56
Answer Key & Solution
Section 1 - MCQ
Q1
12:30:30

Solution

n=45000;

h=45000/ 3600 = 12

m=(45000 mod 3600)/60 =30

s=30mod 60; = 30

12:30:30

Q2
non of these

Solution

It prints 1 then x=1*5 =5 ,loop get iterated and print 5 then x=5*5=25 25>20 so loop terminates.

Q3
7

Solution

Pre increment will be done before adding the values i.e 2+5 = 7

Q4
127

Solution

b=625/5 = 125

a=125+1 = 126

After that a incremented by 1 i.e. 127. a<4 (false) so 127 gets printed.

Q5
87

Solution

If block executes and update c=72.

While executing for loop:

When i=1,c=73

When i=2,c=75

When i=3,c=78

When i=4,c=82

When i=5,c=87.So finally 87 gets printed.

Q6
29

Solution

The binary representation of a & b is

a=6=> 0110

b=8=> 1000

a^b => 1110 (Decimal value = 14)

if 14<6 (False)

so a=6,b=8,c=15

therefore 6+8+15 = 29

Q7
2

Solution

p=3, q=1?

Integer funn( integer p, integer q)

Binary representation :

p=3 => 0010

q=1 => 0001

q&1 => 1 (greater than 0)

p&3 => 3 (greater than 0)

Both the conditions are True so it returns 3^1

p=3 => 0011

q=1 => 0001

p^q=> 0010 (Decimal representation = 2)

Q8
4

Solution

Binary representation for p,q,r is

p=1=> 0001

q=2=> 0011

r= 0=> 0000

1<2 (TRUE)

p= 0001<<1 => 0010

p=2
if(2 > 2) (FALSE)

Therefore 2+2+0 = 4

Q9
114

Solution

Bitwise operators take precedence over relational operators.

In this q^q>1 statement, q > 1 will be evaluated first and enters if block.

r^r > 1 is also executed in the same way.

As a result, p = 1,q = 1,r = 2, Then q is updated to q = 111.

As a result, 1+111+2 Equals 114.

Q10
7

Solution

When the array element is less than or equal to 1, the value of m is changed to the current array value.

m = 1 (end of the loop).

1 ^ 6 => 7 (updated m value)

Output : 7

Q11
134

Solution

Finally funn returns 6+27+78+23 =>134

Q12
6

Solution
If the condition gets failed so only the q value will be updated.

So, p=1, q=2, and r=3.

As a result, 3 will be printed.

Q13
3

Solution

The output value is 3, here if block condition is true.

So p-value is updated as 1.

Q14
15

Solution

Output is 15. Outer if block condition is true but inner if block condition is false, so only qq value is updated to 6.Therefore 5+6+4 = 15.

Q15
9

Solution

Variable 'c' value is updated to a and b.

As a result 3+3+3 = 9.

Q16
4

Solution

Inside for loop, the value of 'a' is added and subtracted by 'c', so there is no change in the 'a' value.

As a result 3+1 = 4.

Q17
31

Solution

In the first, if block 'a' value is

10=>1010

c => 1100

10&12 => 1000 (a=8)

In the second, if block 'a & c' value is

a=8+6+12 =26

c= 26 & 5 => 0

As a result 26+5+0=>31
Q18
6

Solution

Relational Operators have higher precedence than arithmetic operators. So 'p' and 'q' values will get updated to 2.

As a result 2+2+2 = 6

Q19
19

Solution

Inside for loop, the value of b will be updated to 14 for each iteration.

As a result 5+14 => 19 will be printed.

Q20
6

Solution

Inside if block, pp=1=>0001>>1 .

pp right shifted value is 0 (0000).

Again pp is right shifted (i.e 0000>>0).

Therefore pp=0, So output is 0+2+4 => 6.

Q21
32

Solution

Inside for loop:

Iteration 1:

a=19

a=19+5=>24

Iteration 2:

a=23

a=23+5=>28

Iteration 3:

a=27

a=27+5=>32

After loop again 'a' value is updated to a=32-5 =>27

As a result 27+5 = 32

Q22
14

Solution

Binary representation for a,b and c is,

a=3=>0011

b=4=>0100

c=6=>0110

a=3=> 0011

7 => 0111

a&7=> 0011 (3<4 (TRUE))

Inside if block,

'a' value is updated to 4

As a result 4+4+6 => 14

Q23
43

Solution

First, if block will get executed and update the value of 'p' and 'r'.

p updated to 8, 'r' updated to 27.

As a result 8+8+27 => 43

Q24
21

Solution

Because the outer if block condition fails, the variable's value remains unchanged.

As a result 7+7+7 = 21

Q25
2

Solution

Because the outer if block condition fails. So, pp and qq value gets updated.

pp=1+1 => 2

qq=2+1 => 3

Finally prints pp value i.e 2.

Q26
15

Solution
Because the inner if block condition fails, the variable's value remains unchanged.

So 2+13 => 15

Q27
13

Solution

Inside second for loop,

Iteration 1:

c=5

a=1+5 = 6

Iteration 2:

c=6

a=1+6 = 7

Iteration 3:

c=7

a=1+7 = 8

Iteration 4:

c=8

a=1+8 = 9

Iteration 5:

c=9 ; 9<=8 (False)

As a result, 9+4 => 13

Q28
18

Solution

Inside for loop,

In iteration 1:

a=1,c=6

a=1=> 0001

c=6=> 0110

a&c=> 0000 ('a' updated to zero i.e a=0)

a=0,c=6

a=0+6 => a= 6 ('a' updated to six i.e a=6)


In iteration 2:

a=6,c=7

a=6=> 0110

c=7=> 0111

a&c=> 0110 ('a' updated to zero i.e a=6)

a=6,c=7

a=6+7 => a= 13

As a result, 13+5 = 18

Q29
-3

Solution

There are no changes in the value because if block condition fails.

As a result, 2-1-4 = -3

Q30
0

Solution

After duplicating the array's values, all of the array's values and m are set to '0.'

As a result, the value '0' is displayed.

Q31
2

Solution

The value of pp will be 0 at the end of the for loop, and 1 inside the if block.

As a result, it displays 2.

Q32
5

Solution

The if block in the for loop is only run for the array values 0 (update m=1) and 4 (update m=5).

As a result, it shows 5 as a result.

Q33
21

Solution

If block gets executed and set qq as 0.


As a result, it displays 21.

Q34
4

Solution

If block gets executed and set 'a' as 2.

As a result, it displays 2+2 = 4.

Q35
2

Solution

If block condition gets failed and set 'q' as 0.

As a result, it displays 1+0+1 = 2.

Q36
5

Solution

For loop gets executed and set 'q' as 4.

As a result, it displays 1+4 = 5.

Q37
2

Solution

As a result, it displays 2.

Q38
13

Solution

After executing 2^a (i.e 2^2), b is set to 0.

If block gets failed,as a result, it displays 2+0+11 = 13.

Q39
2

Solution

If block gets executed and set 'p' as 0.


As a result, it displays 0^2 = 2.

Q40
22

Solution

First If block gets executed and set 'c' as 14 and second if blocks get failed and set 'c' as 7.

As a result, it displays 8+7+7 = 22.

Q41
27

Solution

If block condition will execute as follows:

i.e (5 ^ 8) = 13 ,( 4 ^ 8 ) = 12 ,So 13 > 12 (True)

(9+15) & 1 => 0 (False)

If block gets failed, as a result, it displays 8+4+15 = 27.

Q42
20

Solution

b value set to 4 (2&2 => 2+2 = 4)

a value set to 8 (5&11 => 1+7 =8)

Output: 8+4+8 = 20

Q43
3

Solution

Value of 'c' copied to 'a', then 'a' value copied to 'b' and 'c'.

As a result, the value of c is assigned to all variables.

Output: 1+1+1 =3.

Q44
1

Solution
Output: 1

Q45
26

Solution

Initially a= 2, b= 4, c= 8

'b' value copied to 'a' (a=4)

8 < 4 (FALSE)

8 & 4 = 0 (0<4 (TRUE)

c=18 ((8^6)+4 => 14+ 4 = 18)

As a result, 4 + 4 + 18 = 26.

Q46
5

Solution

Initially, m=3.

for loop incrementing the 'm' value twice i.e m=5.

Q47
2

Solution

Initially p= 1, q= 1, r= 1

If block gets executed and set 'p' as 0.

So, 0+1+1 = 2.

Q48
24

Solution

For loop executes three-time and set 'q'= 16 for all the iterations.

So, 8+16=24

Q49
4

Solution

If block fails, the value of' m' will not be updated.

As a result, it displays 4.

Q50
19

Solution

Value of 'b' set to 14 after execution of for loop.

So, 5 + 14 = 19

Q51
21

Solution

Initially pp= 1, qq= 50, rr= 20

If block gets executed and set 'qq' as 0.

Output: 1+0+20 = 21

Q52
2

Solution

Initially p=1,q=1

If block gets executed and set 'p' as 3.

Output: 3 ^ 1 => 2

Q53
8

Solution

Initially p=5,q=2

2&5 = 0

5^2 = 7 (0<7 (TRUE))

5^3 = 6 (p=6)

Output : 6 + 2 = 8

Q54
15

Solution

Initially a[4] = {4, 3, 2, 1}


a[0] = 4 + 3 =>a[0] = 7 ({7, 3, 2, 1})

a[3] = 1 + 7 =>a[3] = 8 ({7, 3, 2, 8})

m= 8 + 7 => 15

Q55
2

Solution

Initially a[4] = { 1, 1, 1, 2}

a[2]= 1 - 1 + 2 => a[2]=2

a[3] = 2

m=2

Q56
3

Solution

Initially p= 2,q= 0, r= 0

First If block gets executed and set 'r' as 1.

As a result, it displays 2+0+1 = 3

Q57
-1

Solution

Initially a= 2, b= 2;

Iteration 1:

c=1,a=2

(2&1) -1 => a=-1

Iteration 2:

c=2,a=-1

(-1&2) -2 => a=0

Iteration 3:

c=3,a=0

(0&3) -3 => a=-3

Output: -3+2 => -1

Q58
2

Solution
Finally, 2 gets printed.

Q59
11

Solution

Initially a=6, b= 2, c= 7

After running the for loop, the value of 'a' is set to 5 (the loop runs until the value of 'c' is 5).

Then a= (2+2)+5 => a= 9

Output: 9+2 = 11

Q60
4

Solution

Initially m=1 , a[4]= { 1, 0, 1, 2}

Iteration 1:

0>1(FALSE)

Iteration 2:

1>0 (TRUE)

m=1-0+1 => m=2

Iteration 3:

2>1 (TRUE)

m=2-1+2 => m=3

Iteration 4:

3>2 (TRUE)

m=3-2+3 => m=4

Finally, 4 gets printed.

Q61
7

Solution

Initially str1= "aaAa", str2 = " AAa"

Totally 7 vowel in both string.


Q62
54

Solution

Initially a=9, b = 11, c=9

First if blocks get failed, but second if block gets executed and set c=12 and a=31

As a result 31+11+12 => 54

Q63
2

Solution

Initially p=2,q=3

If block gets fail and set 'q' as 0.

As a result, 2 gets printed.

Q64
16

Solution

Initially a=1, b=6, c=4

c value set as 11 (c=10+1)

If block gets executed and set 'c' as 1. (i.e) (6+9) & 1

15 => 1111

1 => 0001

15&1=>0001 (c=1)

b= 1+7+6 => b=14

As a result, it displays 1+14+1 = 16.

Q65
11

Solution

Initially a=5, b= 4, c =7

After executing first for loop, 'a' set to 3.

After executing first for loop, 'a' set to 1+ 6 = 7 (loop execute until c value is 6)

As a result 7+4 => 11


Q66
11

Solution

Q67
3

Solution

Initially p=1,q=1,r=2

If block gets executed and set 'p' as 0.

As a result, it displays 0+1+2 = 3.

Q68
20

Solution

Initially a=12, b=13

After executing for loop 'b' set to 10 (b=10) and 'b' value copied to a.

As a result 10+10 = 20

Q69
1

Solution

Initially m=1

There are no changes in the value, because both if block condition fails.

As a result, it displays 1.

Q70
30

Solution

Initially p=6, q= 9, r= 7

7=>0111

6=>0110

&=>0110 (7 & 6 = 6)
9=>1001

7=>0111

^=>1110 ( 9 ^ 7 = 14)

If block gets executed and set 'r' as 3 and 'q' as 21.

As a result, it displays 6+21+3 = 30.

Q71
12

Solution

While j=3 ,

The value 'm' is used as the array's third index value, which is 12.

As a result, it displays 12.

Q72
4

Solution

Initially a=1, b= 3, c= 2

If block condition gets failed,so 'b' value is set to 1. (b=3&1 => b=1)

As a result, 1+1+2=4

Q73
654

Solution

Initially, i=3.

Iteration 1:

prints 6 and update i=2

Iteration 2:

prints 5 and update i=1

Iteration 3:

prints 4 and update i=0

When I equals 0, the loop is terminated.


Q74
11

Solution

Initially a=2,y=3

For each iteration of the loop, x=0,1,2 'a' is increased by three.

Iteration 1:

a=2+3 =>a=5

Iteration 2:

a=5+3 =>a=8

Iteration 3:

a=8+3 =>a=11

Q75
It will print the reverse number from 12 to 0 except 1

Solution

Initially a=13, Inside loop 'a' value decrements and printed 12

In next iteration a=12, Inside loop 'a' value decrements and printed 11.

The same process is repeated and prints 10,9,8,7,6,5,4,3 until 'a' value is 3.

When a=3, 'a' value decrements and prints 2 then the loop terminates.

Then 4/6 = 0 gets printed

Q76
1

Solution

a[1]= 0+2 = 2 // {0,2,0,2}

a[2] =2+0 = 2 // {0,2,2,2}

a[3]= 2 // {0,2,2,2}

m=2

If block executes and decrement m value (m=1)

Q77
None of the mentioned option

Solution

Recursive function call: fun(22,4,2) --> fun(20,6,4) --> fun(16,8,6) --> fun(10,10,8) --> fun(2,12,10) --> fun(-8,14,12)

In fun(-8,14,12) function call do nothing and control transfer to previous call fun(2,12,10).

In fun(2,12,10) function call prints 12 and control transfer to previous call fun(10,10,8).
In fun(10,10,8) function call prints 10 and control transfer to previous call fun(16,8,6). This process repeats upto first function call

fun(22,4,2)

Q78
-3

Solution

fun(125) --> fun(23) --> fun(2)

In fun(2) function call -3 value returned to fun(23) and from that again -3 returned to fun(125) and gets printed.

Q79
-5

Solution

Initially p=1, q=4, r=2

1^4 = 5 , 1&4 =0 , so if block executes r=1&4 =0

Second if block gets failed and print 1-4+0-2 = -5

Q80
14 50 40 30 9 4 -1

Solution

When an integer is divided by another integer, the result is an integer. 60/15=4, so the loop executes four times.

Inside for loop

Iteration 1:

c= 4+15-5 => 14.

Inside while loop:

a=60-10=> 50 .

b=15-5=>10 .

(Similarly, the while loop is repeated three times until b is less than or equal to zero, and then the value of 'a' is printed by decrementing it

by ten times).

Initially, c value 14 gets printed then 'a' value thrice 50 40 30.

Then c value update again c= 14+0-5 => 9 gets printed. Similarly, the for loop is repeated until 'i' becomes 4.

Q81
42

Solution
Initially x= 75. 75-35(40) which is greater than 18 (75/4). So fun() returns 37+5 i.e 42.

Q82
14:12:6

Solution

Initially a1=2, b1=45, c1=36, a2=11, b2=26, and c2=30. c=66 (36+30). b=1 (66/60 ). c= 6 (66 mod 60). b= 72 (1+ 45 + 26). a= 1 (72/60) . b=

12 (72 mod 60). a= 14 (1+2+11)

As a result, 14:12:6 gets printed.

Q83
5

Solution

Initially a=5 , b=4.

Four greater than five (FALSE), five greater than zero (TRUE). Logical OR operator(||) returns the boolean value TRUE or (1) if any of the

conditions are TRUE. Inside if block, 'b' assigned with 'a' value (b=5) and a=0. Next, if block condition gets failed and prints 0+5 = 5 .

Q84
5

Solution

In bitwise exclusive OR ,if one bit is 0 and the other bit is 1, the corresponding result bit is set to 1.

If you apply bitwise exclusive OR to the same number, the outcome is zero.

So else block gets executed and assign b=2. As a result, 3+2 =5 gets printed.

Q85
13

Solution

Initially a=1, b=4, c=3. Logical AND operator (&&) returns the boolean value TRUE or 1 if all the conditions are TRUE.

All the values except zero are considered as TRUE values.

Because both the if block conditions are TRUE in this case, it is executed and the values a=2 and b=8 are updated.

As a result, 2+8+3= 13 gets printed.

Q86
5

Solution

integer a=1.

Iteration 1:

1<5 (TRUE)

a=3

Iteration 2:
3<5 (TRUE)

a=5

Iteration 3:

5<5 (FALSE)

So, 5 gets printed.

Q87
15

Solution

Initially m=9, n=6. m updated to 10 by incrementing m by 1 and n updated to 5 by decrementing n by 1. Then m=10+5 = 15. Here 15 > 5

(TRUE) so if block gets executed and prints m value 15.

Q88
a=3, b=4, c=5

Solution

Value 'a' should be greater than 'b' or 'c' to execute first if block. Then the sum of 'a+b' should be greater than 'c' and 'b' should be less than

'c' to execute the next if block. So a=3, b=4, c=5 is the only option that satisfies the above constraints.

Q89
2

Solution

Initially a=2, b=2, zero is considered as FALSE value, so else block executes and update a=0. As a result, 0+2 = 2 gets printed.

Q90
none of the mentioned options

Solution

Initially n=1, loop runs only once and assign b= 1 (1 mod 4 = 1) .Modulo operator gives reminders. If block condition gets failed and prints

b value i.e 0. So, none of the options.

Q91
343 342

Solution

Initially, n=343, m= n

Logic inside the while loop is used to reverse the number. If the reversed number is the same, the next number will be printed; otherwise,

the previous number will be printed.

Q92
10

Solution
Initially a=3, b=2, c=1, d=10

a= 3<<3 => 0001 1000 => 24

b=2<<2 => 0000 1000 => 8

c=1<<1 => 0000 0010 => 2

2 mod 24 =2 , 2 mod 8 =2 (both the values are not equal to zero, so if blocks wont get executed and prints 'd' value (10).

Q93
calculates x+x*y

Solution

In this program fun() is called repeatedly and added up until y becomes zero. Repeated addition is called multiplication i.e x*y.

Q94
8

Solution

Initially a=2, b=4,c=9.

5=> 0101

2=> 0010

4=> 0100

^=> 0011 (3)

If block executes and update c=2.

As a result, 2+4+2 = 8 gets printed.

Q95
23

Solution

Initially a=4,b=9.

If block executes and update a=4+9 (13), a= 13+9 (22), b=9+22 (31).

Second if block gets failed and execute else block.b=31-22 (9).

22=>0001 0110

09=>0000 1001

^ => 0001 1111 (31)

09=>0000 1001 (9)

31=>0001 1111

^ => 0001 0110 (22) (b=22)

Again a value updated to 1. As a result, 22+1 =23 gets printed.

Q96
40
Solution

for funn(8,8) => 8+funn(6,6)+8 ,

funn(6,6) => 6+funn(4,4)+6 ,

funn(4,4) => 4+funn(2,2)+4 ,

funn(2,2)=> 2+funn(0,0)+2 ,

funn(0,0) => 0 ,

funn(2,2) => 2+0+2 => 4 ,

funn(4,4) => 4+4+4 => 12 ,

funn(6,6) => 6+12+6 => 24 ,

funn(8,8) => 8+24+8 => 40 gets printed.

Q97
7

Solution

Initially p=1,q=1,r=3,

p=1+(1^3)&1 = 1

p= 1+((1 ^ 3)&1) = 1

q=1+((1 & 3)^ 1) = 1

q=3+((1 & 3)^1) = 3

As a result, 1+3+3 = 7.

Q98
14

Solution

Initially a=4, b=6 ,

funn (4,6) => return 4+6+funn(5,1).

funn(5,1) => return 4.

funn (4,6) => return 4+6+4 => 14 gets printed.

Q99
1.000000

Solution

Given condition is true so it returns a value 1. Double prints the value with 6 decimal places, so 1.000000 gets printed.

Q100
25

Solution
In fun(20,25,30), recursive function call made for fun(-10,25,27) => p less than 1 so moves to previous call and execute remaining

instructions. (i.e) here q value gets printed.

Q101
It will print Hello one time

Solution

Initially, i=3, j=5, j less than 6 condition is true, so it prints "Hello" and increment j value. Now j less than 6 condition is false. So,"Hello" was

printed only once.

Q102
405

Solution

Initially p=15,q=3

r=15/3 = > r=5

q= 15 mod 5 =>q= 0

p=(15+ 0+ 5)/5 = 20/5 =>p=4

Q103
14

Solution

In funn(7,4) => recursive function called 7+fun(-3,3)+4;

In fun(-3,3) => return 3.

So in funn(7,4) => 7+3+4 => 14 gets printed.

Q104
10 15 20 25 30 6 35 7

Solution

In fun1(35)=> fun1(30) => fun1(25)=> fun1(20)=>fun1(15)=>fun1(10)=>fun1(5)

In fun(5) => does nothing and backtrack to fun1(10) [pending instruction get executed] prints n value (i.e) 10 and fun1(10/5)

[fun1(2)]called and do nothing.Again recursive call backtrack to fun1(10) and backtrack to fun(15) and do same process repeatedly and

prints 15,20,25.While backtrack to fun1(30) [pending instruction get executed] prints n value (i.e) 30 and fun1(30/5) [fun1(6)]called and

then 6 gets printed. Similarly recursive call gets executed and prints 35,7.

Q105
18

Solution
Initially x=7, y=9

z= 7+9 = 16

y = 16 mod 7 => 2

x= 7+2 => 9

y =9+16 => 25

Iteration 1:

y=25-3 => 22

Iteration 2:

y=22-4 => 18

Q106
-2

Solution

Initially a=4, b=2, if condition gets failed and return 2-4 (-2) gets printed.

Q107
5

Solution

integer a=1.Iteration 1: 1<5 (TRUE)a=3, Iteration 2: 3<5 (TRUE) a=5 , Iteration 3: 5<5 (FALSE) So, 5 gets printed.

Q108
14

Solution

Initially p=3, q=7

r=3,p=7,r=7,q=7,p=7. As a result, 7+7 = 14 gets printed.

Q109
5

Solution

x=45 , 45 MOD 6 => 3 MOD 2 =1.

1>0 (True), return (45/9) i.e 5

Q110
-7

Solution

Here nested recursive call is done. For i=12 ,

In fun(12) , 6<0 (False) so fun(fun(6)) is called.

In fun(6), 3<0 (False) so fun(fun(0)) is called


In fun(0), 0<0 (Fasle) so fun (fun(-6)) is called.

fun(-6), -3<0 (True), it returns -6+1 (-5) to previous function call. So fun(-6) replaced with -5. As a result fun(-5) is called. This process

repeated until fun(12).

So, Each function call and the return values are:

fun(12)=6,

fun(6)=0,

fun(0)=-6,

fun(-6)=-5,

fun(-5)=-4,

fun(-4)=-3,

fun(-3)=-9,

fun(-9)=-8,

fun(-8)=-7 . Finally -7 gets printed.

Q111
2

Solution

Initially c=2, a=9, b = 7, b= 7 % 2=> b=1 , a= 9%2 => 1. As a result, 2 gets printed.

Q112
5

Solution

Initially, the string length is 8. At 5th index Null included. Null is considered as an end of a string. So now the string is "ABCDE", current

string length is 5.

Q113
10 36

Solution

Initially a=3, b=2, c=0. Inside while loop, c updated to 5, a updated to 8.Inside else block b updated to 10 and gets printed. In the next

iteration, c updated to 18, a updated to 26. Inside else block b updated to 36 and gets printed. In the next iteration, c updated to 62, a

updated to 88,Now 88> 30 so jump out of the loop.

Q114
6

Solution

Initially p[5]={1,4,5,6,7}.

1=> 0001

4=> 0100
&=> 0000 (0) . First If block wont execute.

5=> 0101

7=> 0111

&=> 0101 (5). If block gets executed and update m value by 6 and gets printed.

Q115
0

Solution

Initially p[3]={1,7,6}. All the values in the array are added to the index value and updated in the array inside the loop.(i.e) {(1+0),(7+1),(6+2)}

= {1,8,8}.

8=> 1000

2=> 0010

&=> 0000 (0) gets printed.

Q116
29

Solution

Initially n=10, val=0,Inside for loop :

Iteration 1:

val=0+10 =10

val=10+10 =20

Iteration 2:

val=1+10= 11

val = 11+10=21

Similarly, the loop executes and increases 'val' value by 1 till 'i' is less than or equal to 9.

As a result, 29 get printed.

Q117
5

Solution

Initially pp=4, qq=2, Inside for loop :

rr=1,pp=2+1 =>p= 3, 2> 1(TRUE) so control comes out of the loop.

As a result, 3+2 = 5 gets printed.

Q118
11

Solution
Initially a=1,b=3,c=7. a=1+3 => 4.

7 = 0111

4 = 0100

^ = 0011 (3). 3 + 3 =6 , so it is considered as true and if blocks executes and update a & b value (a=2, b=2) . As a result, 2+2+7 = 11 gets

printed.

Q119
p=12,q=7,r=-1

Solution

For p=12,q=7,r=-1, p=12+7-1-9 =>p=9,

q=(9+7)/2=> q=8

Here p is greater than q so "inside if gets printed.

Q120
1

Solution

Logical operator returns either TRUE (0) / FALSE (1)

All the values except 0 are considered as TRUE.

The logical-AND operator produces the value 1 if both operands have nonzero values.

The logical-OR operator performs an inclusive-OR operation on its operands. The result is 0 if both operands have 0 values. If either

operand has a nonzero value, the result is 1.

Initially x=2,y=1,z=5

a=(TRUE AND TRUE) = TRUE (1).

a= TRUE OR TRUE => TRUE (1).

a=1 gets printed.

Q121
36

Solution

Initially m=0, a[4]={10,11,3,2}.

The current index array value is assigned inside the for loop by adding the previous array value by two.

End of the loop a[4]= {10 12 14 16}

m=10+12+14 => 36 gets printed.

Q122
28

Solution
Finally, 28 gets printed.

Q123
14

Solution

Here just a and b value updated by adding it twice eg: a= 6+6 =12, b=1+1 = 2 and finally 12+2 = 14 gets printed.

Q124
40

Solution

Initially a=50, inside fun() 'b' set as 10.

fun() returns 50 -10 => 40.

As a result, it displays 40.

Q125
64

Solution

Initially a1 =8.

When you divide an integer by an integer, you'll get an answer in an integer.(5/7 =0).

8+0*4 (Apply VBODMAS rule)

8+0 => 8

Finally 8 gets printed.

Q126
6

Solution

Initially x= 0, y= 1

Iteration 1:

x= 0, y= 1,z=0

x=0+1+0 => x=1

Iteration 2:
x= 1, y= 1,z=1

x=1+1+1 => x=3

Iteration 3:

x= 3, y= 1,z=2

x=3+1+2 => x=6

Iteration 4:

'z' value exceeds 2 so the loop terminates and prints the value 6.

Q127
6 6 12

Solution

Initially r=0 p=6 q=3

While(1) means infinite loop, the loop only breaks if the value of 'p' is larger than 23.

Iteration 1:

r=6-3 => r= 3

p= 6+3 => p=9

Else block get executed and updated q=9-3 => q=6 (q value gets printed)

Iteration 2:

r=9-6 => r= 3

p= 9+3 => p=12

Else block get executed and updated q=12-6 => q=6 (q value gets printed)

Iteration 3:

r=12-6 => r= 6

p= 12+6 => p=18

Else block get executed and updated q=18-6 => q=12 (q value gets printed)

Iteration 4:

r=18-12 => r= 6

p= 18+6 => p=24

If block gets executed and breaks the loop.

Q128
20

Solution
Function call starts from calculate(18), then it calls itself until 'b' reaches 1. Function returns 0 to calculate(1) ,calculate(2) return 5 by

adding 5+0. Same process repeated upto calculate(18). In calculate(18), 5+15 = 20 . Final value(20 ) returned to main method and gets

printed.

Q129
it will print the sum of the elements of the first row of the given 2-D array

Solution

Inside for loop, when 'k'=0, j varies from 0 to 2 i.e a[0][0],a[0][1] and a[0][2]. All the zeroth row value gets aggregated and loop breaks. Final

sum value will be 1+2+3 = 6.

Q130
1

Solution

Initially b=1, c=1

'b' (1) right-shit by 1 , set b value as 0.Then c value left-shift by 0 will not update c value.

As a result 0+1 = 1 gets printed.

Q131
54

Solution

Inside for loop, initially j=0,array1 [0]%3 =0 (True) so it executes if block and update q and p value. The same process is repeated until j

value reaches 5.

While j=0 , p= -6, q= -6

While j=1 , p= 24, q= 27

While j=2 , p= 24, q= 31

While j=3 , p= 24, q= 33

While j=4 , p= 24, q= 44

While j=5 , p= 24, q= 54 (then loop terminates and print q value as 54)

Q132
it will print 'laptop' 6 times
Solution

Inside for loop, while a=0, inner for loop runs once.

while a=1, inner for loop runs twice.

while a=2, inner for loop runs thrice.

Totally loop runs six times and the "laptop" gets printed six times.

Q133
n-2

Solution

The fibonacci series number is the sum of the two preceding ones. So call function Fibonacci(n-1) + Fibonacci(n-2).

Q134
0

Solution

Because the p value has not been initialized, the compiler will use 0 as the default value and so 0 gets printed.

Q135
24

Solution

Initially q=12, r=3.

While loop executes until q is less than r-1.

Iteration 1: (12 > 2)(TRUE)

r updated to 6

s updated to 18

t updated to 8 [ (18%4)+6 => 2+6 => 8]

Iteration 2: (12 > 5)(TRUE)

r updated to 12

s updated to 24

t updated to 12

Iteration 3: (12 > 11)(TRUE)

r updated to 24

s updated to 36

t updated to 24

Iteration 4: (12 > 23)(False) So it compares s and t and prints t value as 24.

Q136
1

Solution
When two identical numbers are bitwise XORed, the outcome is zero.

eg: 1 ^ 1 =0

1 => 0001

1 => 0001

^ => 0000

a= ( 1 ^ 1) & (1 ) + (1 ^ 1) & (1) =>a=0

Then 0+1 =1 which gets printed.

Q137
it will swap the values of first and second and double

Solution

Both values are swapped here, and the second*2 instruction doubles the second value.

Q138
12

Solution

Initially a =5 , b=300 and c=1

Inside loop:

while b=0 : a incremented by 1 (a=6)

while b=1 : a incremented by 1 (a=7)

while b=2 : a incremented by 1 (a=8)

while b=3 : a incremented by 1 (a=9)

while b=4 : a incremented by 1 (a=10)

while b=5 : a incremented by 1 (a=11)

Then 'a' is added with 'c' (11+1) and prints 12.

Q139
20

Solution

When two identical numbers are bit-wise AND, the outcome is the same number.

eg: 10 & 10 = 10

10 => 1010

10 => 1010

& => 1010 (10)

Then by adding 10 + 10 = 20 gets printed.

Q140
12
Solution

The value of b is 300, a is 5 and c is 1Check the condition whether b is greater than a, it becomes true so the value a is assigned to be, b

becomes 5For loop starts from 0 and ends with 5, for every iteration we are going to add 1 to the variable a and assign it back to a.After

the iteration of for loop, the value of a becomes 11 Print the sum of a and c, the output is 12

Q141
2

Solution

The value of j is 16, i is 8 k is 2 and m is 1when we perform j ^ i, it result in 24 and performs mod by k which is 2, it result in 0 then compare

it with 0 and the condition becomes trueadd 1 to m.The output is 2.

Q142
it will print "STUDENT" only one time

Solution

The value of x is 15when we check the condition in the while loop, it is true so it prints the student once and breaks the loops, the answer

is it will print "STUDENT" only one time

Q143
2 2 6 4 10

Solution

The iteration of the for loop starts with 0 and ends with 4 itself, only for even indices, the value will be multiplied by 2 and results in 2 2 6 4

10

Q144
6

Solution

The size of the array arr is 6 , the size of arr[0] is 1 and the totally array has 6 characters. When we divide 6 by 1, it becomes 6.

Q145
1

Solution

The value of b is 1, a is 5 and c is 1Check the condition whether b is less than a, it becomes true so we assign the value a in b, the value of

b becomes 5Now for loop starts iteration from 0 to 1^2^3, the variable b is assigned for the for loop and starts the iteration from 0 when

we perform 1^2^3 it results in 0, the loop condition executes once, then the value of b is updated as 1.

Q146
6

Solution

the value of x is 0 and y is 1for loop will iterate from 0 to 1 because it will consider the condition as z <= 2 so 2 will not be considered, 0th

iteration x is 0, y is 1, z is 1, Sum of these 3 values result in 1 which is stored back in x, 1th iteration x is 1, y is 1, z is 1, Sum of these 3
values result in 3, which is stored back in x, 2nd iteration x is 3, y is 1, z is 2, Sum of these 3 values result in 6, which is stored back in x

Finally, it prints the output as 6, the value of x

Q147
109

Solution

The value of i is 100

we have to perform mod operation for i and the answer for exor operation for 1 and 2

The result for exor operation for 1 and 2 is 3, the value of i is 100 when we perform 100 mod 3, the result will be 1 which equals to 1 as per

the condition given so if the condition becomes true.

Now add 9 to i value which becomes 109

The output is 109

Q148
7

Solution

The value of a is 5

Then a is added with 1, it becomes 6

Then a is multiplied by 2, it becomes 12

Then a is divided by 2, it becomes 6

Then a is divided by 5 which results the answer as 1 and added with 6, it becomes 7 which is assigned to p

The output is 7

Q149
18

Solution

Hint 1The value of a1 is initialized as 15Then a1 is subtracted by 1, it becomes 14Next a1 is multiplied by 2 and added with 8 so it

becomes 36Next a1 is divided by 2 and added with the result of 9 * 5, it becomes 63then 63 divided by 5 it becomes 12 then added with 6,

it becomes 18 which will be assigned to p1. Finally, when we print p1, it prints 18 as output

Q150
40

Solution

The value of an array is 1 1 2 2

The value of a[0] is 1 + 1 + 2 + 2 = 6

The value of a[1] is 6 + 1 + 2 + 2 = 11

The value of a[2] is 6 + 11 + 2 + 2 = 21

The value of a[3] is 6 + 11 + 21 + 2 = 40


The value of a[3] is assigned to m

The output is 40

Q151
6

Solution

The value of a is 3 and b is 1Outer for loop iteration starts from 1 and ends with 2, for every iteration, the value of a is added with 1. After

the iteration of for loop, the value of a is updated as 5. Finally, it prints the output as the sum of a and b which is 6

Q152
7

Solution

The value of a is 1, b = 6 and c is 12

Check a is greater than b, it becomes false so else case will be executed

The output is sum of b and 1 which is 7

Q153
3

Solution

The value of a is 3 and b = 1for loop starts from 1 and ends with 2c=1the sum of a and b is 4 is greater than 0 if condition becomes true

so the value of a is assigned to b, b becomes 3 and the loop gets continuedNow the value of b is 3 c = 2the sum of a and b is 6 is greater

than 0 if condition becomes true so the value of a is assigned to b, b becomes 3 and the loop gets continued till it c <= 3. The output prints

the value of a which is 3

Q154
16

Solution

The value of s is 12, k is 14 and m is 2

The function mul takes three arguments which is 12, 14, 2

By checking the condition the sum of s and m is greater than 1

return 12/2 is 6 + 14 mod 5 is 4 + recursive call mul(4, 7, 1)

The function mul takes three arguments which is 4, 7, 1

By checking the condition the sum of s and m is greater than 1

return 4/1 is 4 + 7 mod 5 is 2 + mul(1, 3, 0)

The function mul takes three arguments which is 1, 3, 0

By checking the condition the sum of s and m is not greater than 1 so it returns the value 6 to the previous recursive call

and the value 6 is returned to previous recursive all and that function returns the sum of 10 and 6 and finally 16 is returned by the function
Q155
2

Solution

Initially a=1,b=1. Inside for loop 'a' increased by 1 and inside if block 'a' decrement by 1 until c reaches 7 i.e value of a is not changed.

Finally it prints 1+1 => 2 .

Q156
8

Solution

Initially a=3,b=2.

Inside first for loop a decremented thrice.(a=0)

Inside second for loop 'a' incremented by 2 thrice.(a=6)

Finally, 6+2 => 8 gets printed.

Q157
2

Solution

Because the values of a1 and a2 are positive, it returns true for the given condition and set p=1 and p not equals 0 (true), So 2 gets

printed(1+1 is 2).

Q158
21 24 27 30

Solution

Because for loops run four times, the b value is added by three for each iteration.

ie 18+3 => 21, 21+3 => 24 ,24+3=>27, 27+3 => 30

Q159
6

Solution

If block and else if block condition gets failed, so else gets executed and prints c value(6).

Q160
0

Solution

The arithmetic operator has higher priority than the Logical operator.So 6 / 23 = 0 (0 && anything = 0).

value of 'j' set to 0, 0+0 = 0 gets printed.

Q161
3
Solution

Inside for loop a decrement by 1(a=2) and breaks out of the loop because d< 2( d value set as 0 by default).

As a result it print 3 (2+1 = 3 )

Q162
17 15 4

Solution

Apply VBODMAS rule to evaluate the expression.

For loop twice for a=1 and 2.

When a=1, b is updated as 17 and gets printed.

When a=2, b is updated as 15 and gets printed.

When a=3 loop condition gets failed and prints a+1 (i.e) 4

Q163
test1 test completed

Solution

Apply VBODMAS rule to evaluate an expression.

6 / 7 = 0 so k value set as 0.

k lessthan equal to 0 (Ture) so executes nested if condition (i.e) k equals to 0 (true) so test1 gets printed and last instruction prints "test

completed".

Q164
0

Solution

Initially a[4]= {0, 1,0,2}

a[0] = 0-0+2 (i.e){2,1,0,2}

a[1] = 2 -2 (i.e) {2,0,0,2}

a[2]= 0 - 0 (i.e) {2,0,0,2}

a[3] = a[2] (i.e) {2,0,0,0}

a[3] copied to m and prints m value 0.

Q165
it will print biography 1 time

Solution

Initially n=15

while condition true so "biography" gets printed and n=15+2 => n=17.
n value greater than 15 so loop terminates.

Q166
11

Solution

combine(8) will call combine(16) and combine(16) will call combine(32),here 32>=17 so it return 32+3 = 35 to previous call. This process

repeat until it reaches first function call i.e combine(8). combine(8) returns 8+3 = 11.

Q167
44

Solution

compact(22) will be called recursively.

The base condition returns double the value of the given value in this case. So 22 * 2 => 44.

Q168
99

Solution

f5(100) function called then it recursively call f5(99) , 99 % 2 =1 ,so it returns 99 (because it is pre-increment).

Again f5(99) called, 99 % 2 =1 ,so it returns 99 and gets printed.

Q169
2

Solution

The value of the variable a is 2 and b is 7, the first if condition becomes true so it will enter inside the if condition and checks the second

condition if(b+1), it is true so it returns the value 2 from the function. Hence the output is 2.

Q170
Aptl

Solution

The characters in the even index will be printed. When an index is an odd number, space is printed.

So for given string "Alpital", A p t l gets printed.

Q171
56

Solution
Q172
1

Solution

While loop executes once and print p (1) value gets printed and breaks the loop.

Q173
80

Solution

Initially x=3.

Inside do-while loop x decremented to 2 , and printed 2*4 =8 and checks x not equal to 2 (False) so loop terminates.

Apply VBODMAS to evaluate expression

2*(2/6)

=> 2*(0)

=> 0 (gets printed)

Q174
4

Solution

Initially a[4]={1,1,2,2}

a[0]=1+1 = 2 // {2,1,2,2}

a[1]=1+2 = 3 // {2,3,2,2}

a[2]=2+2 = 4 // {2,3,4,2}

a[3]=2+2 = 4 // {2,3,4,4}

m value set as last element in the array (m=4) and gets printed.

Q175
65
Solution

Initially f= 9, k= 55.Apply VBODMAS rule to evaluate the expression.

j value evaluated and set as 16. If block gets executed and set f as 10.

As a result it prints 65(10 + 55= 65).

Q176
It is working

Solution

If blocks execute because k is a positive value and prints "it is working” once.

Q177
1

Solution

If block condition fails, So there are no changes in the value.

As a result, 3-2=1 is the result (gets printed).

Q178
0

Solution

Apply VBODMAS to evaluate the expression.

6 divided by 23 gives 0 (j=0).(0 && anyvalue =0) .So if block gets failed and 0*0 = 0 gets printed.

Q179
-3

Solution

Initially a=-3, b= -2.

For loop gets executed twice and increment the 'a' value (i.e) a= -1 when loops terminates.

As a result , -1 +(-2) = -3 (gets printed)

Q180
1,1,1

Solution

When a user tries to assign more than one value to a variable, the first value is assigned to the variable.

Q181
67

Solution
Initially arr[3][2] = { { 12, 21},{13, 54},{ 52, 63} },x=1.

Outer for loop executes four times (i.e for 'k' values 0,1,2,3)

Inside loop runs for (0,0) , (1,1) , (2,2) and (3,3)

Iteration 1: x value updated to 13 (i.e) arr[0][0]+1= 12+1 => 13

Iteration 2: x value updated to 67 (i.e) arr[1][1]+13= 54+1 3=> 67

Because the loop accesses beyond the array size, the array value will be 0 for the next two iterations. So there is no changes in 'x' value

and 67 gets printed.

Q182
1

Solution

When you divide an integer by another integer, the outcome is also an integer.

Initially a=5, b= 8

8 / 5 = 1 , and 5/8 =0 (loop terminates because condition gets failed)

As a result, 1 gets printed.

Q183
when the value of a= 13

Solution

The program executes for all the odd numbers greater than 12, because the modulo of 2 result should not be equal to 0 (which means odd

values). Then 'a' should be greater than 12. So when the value of a= 13 option satisfies the above constrains.

Q184
1

Solution

Initially a= 3, b= 1

Inside for loop, 'a' value gets decremented for following d and c values.

(1, 1 ), (2 ,1), (2 ,2), (3 ,1), (3 ,2) (i.e) five times. So, a=3-5=> a= -2

'a' value gets incremented for following d and c values.

(0 ,1), (0 ,2), (1 ,2) (i.e) three times.So, a=-2+3=> a= 1

Q185
you are promoted

Solution

Apply VBODMAS rule to evaluate the expression.

Initially k= 2, p= 6

i= 2 / 6 + 3 * 2/ 6 ( 0 +6/6 => 1) (i=1)


If block gets executed and prints "you are promoted". If block is executed, the next blocks (else if) are skipped.

Q186
32

Solution

Initially a=11, b= 21. There are no changes in the variables because if block condition fails for all loop values.

So 11+21 = 32 gets printed.

Q187
6

Solution

Initially b= 2 and a= 2 + 3 (a=5)

5 && 2 =0 , 5 && 1 = 1

If block executed for all the values except 0. Here if condition expression result value is -1 (which is considered as true) and increments 'a'

value.

As a result, 6 gets printed.

Q188
1

Solution

The logic of the program is to find a number of digits in the number. The total digit for the given number 128 is 3, so 'c' decrements three

times (4-3 = 1)

As a result, 1 gets printed.

Q189
45

Solution

Initially a[5]= { 1,2,3,4}

Inside loop all the array element are added twice and added again with 6 . Final result add with 1 (m value)

i.e a={1+1+6+2+2+6+3+3+6+4+4+6} + 1 (m value)

As a result, 45 gets printed.

Q190
two times

Solution

Initially k= 1, p= 4

j= 4 + 0 = 4

if block condition is true so hello prints once and j value updated to ( j= 4 + 0 = 4) .

Second if block condition is gets false and print outside hello.


So twice hello gets printed.

Q191
hello

Solution

i value set as 57 (shown below) , so if block gets executed and prints "hello"

Q192
2

Solution

Initially a= 1, b= 2

Else block gets executed assign a=0.

As a result 0+2 = 2 gets printed.

Q193
6666

Solution

'd' value gets printed for below a,b and c values. (i.e) (a,b,c)

(1,1,1) , (1, 1, 2), (1, 2, 2), (2, 2,2) (totally 4 times 'd' value gets printed.

Q194
2

Solution

Initially a= 108, b= 2, c= 3

If block gets executed and update b value to 2 and b gets printed i.e 2.

Q195
9

Solution

In this recursive program, the recursive call is made until 'a' value becomes 0. fun(0) function call returns 9 and that value is passed to the

first function call and 9 gets printed.

Q196
1
Solution

Initially i=45

If condition becomes true

(i.e) 45 %2 ==0 (False)

45%2 = 1(True)

i=45 (Except 0 all values are considered as True)

Therefore False OR True And True => True

Then 45%2=1 gets printed.

Q197
Functions fun finds the largest element of the linked list

Solution

While loop runs until pointer value becomes null (i.e) last value in the linked list.

When x is less than the current node value then update x with the current node value. Finally, x holds the maximum value in the linked list.

Q198
8

Solution

Initially str1= " momo" (length =4). For loop executes twice and append "mm" for each iteration.So 4+2+2 = 8.

Q199
it will print engineering 2 times

Solution

Initially a=10. 10 not equal to 5 (TURE) so the "engineering" string was printed and 'a' updated to 9. The else block is executed, and the

loop is exited.

Then a is 9 which is not equal to 2 , so again else block is executed and print "engineering". Totally two-time "engineering" gets printed.

Q200
10 times

Solution

"btech" gets printed for below a,b values.

(i.e) (0, 0), (1, 0) , (1, 1), (2, 0) , (2, 1), (2, 2), (3, 0), (3 ,1),(3, 2),(3, 3)

Totally ten times "btech" printed.

Q201
20

Solution

foo(3,4) --> foo(2,12) --> foo(1,19) [returns 19+1 = 20]

20 value returned to the first function call and gets printed.


Q202
4

Solution

fun(2) --> return 1+fun(1) --> return 1+fun(0)

In fun(0) , p=1+1 = 2 . returns 0+2 = 2

In fun(1) , 1+ 2 = > returns 3

In fun(2), 1+3 => returns 4

Q203
3579

Solution

Array values a[10]= { 1,2,3,4,5,6,7,8,9}.

i=1=> a[1/2] => a[0] = 1 => if block prints a[1*2] = 3

i=2=> a[2/2] => a[1] = 2 => if block prints a[2*2] = 5. Similarly loop executes for i=3,4 and prints 7 and 9.

Q204
0

Solution

0=> 0000

1=> 0001

2=> 0010

3=> 001 1

---------------

^=> 0000

----------------

Q205
42 43 44 45

Solution

Loop executes for h value from 42 to 45.

After that, the else block is executed, and the loop is exited.

Q206
Respect

Solution

Initially, array holds p[20]= "Respect Your elders"


First while loop copies the array until the string encounters the null character of space. For given string after "Respect" loop terminates

because of the space character.

In second while loop prints the "Respect" string which is stored in b array.

Q207
9 10 9 8

Solution

Initially k= 1, m= 9

If block executes and prints m value 9 and increment it m=10.

Then second if block gets failed and execute for loop.

For loop run thrice (m=10,9,8) and prints k value.

Q208
It will print nothing

Solution

Initially s=78

While loop runs until s less than 89. After executing the continue statement, loop skips the below instruction and continue the next

iteration) until s value becomes 89.

Q209
18

Solution

Initially arr[]={10,7,2,6,1,2,3}

For loop runs three time for p=0,1,2

arr[3] value added thrice (6+6+6 = 18)

Q210
50

Solution

Initially arr[]= {10, 20,30,40,5}

a= 20 +30 (1st and 2nd index value added and assigned to 'a')

As a result 50 gets printed.

Q211
2

Solution

In for loop b value varies from 0 to 1. ( 2 power 3 =8 , 1 power 8 =1)

For each iteration b increment by 1. So when b=1 (b=1+1)


So b gets printed.

Q212
0

Solution

Any number mod 1 gives answer 0.

Here is the math to illustrate how to get 20 mod 1 using our Modulo Method:

20 / 1 = 20

20 x 1 = 20

20 - 20 = 0

Thus, the answer to 20 mod 1 is 0.

Q213
3

Solution

Recursion starts from the main method.

Q214
10

Solution

Initially b=5, a=2, c=2

If block gets executed and assigns c value to a (a=2)

Second, if block also gets executed and increment c (c=3)

Sum of 2+5+3 = 10 gets printed.

Q215
10 12 13 86 777

Solution

When fun(777) : 777 >12 , 777/9=>86 , fun(86)

When fun(86) : 86>12 , 86/9=>9 , fun(9)

When fun(9) : 9>12 (false so else block executes), Inside else block 9 added with i value and gets printed as 10,12,13. Then backtracking

will happen to fun(86) and prints 86. Then again backtracking will happen to fun(777) and prints 777. So output is 10 12 13 86 777.

Q216
None of the mentioned options

Solution

When fun(4,2) => 4>1 so if block executes and call fun(2,4).

When fun(2,4) => 2>1 so if block executes and call fun(0,6).

When fun(0,6) => 0>1 (false) so print statement executes and print 6. Then function call backtrack to fun(2,4) and executes print

statement and print 4.

Then again function call backtrack to fun(4,2) and executes print statement and print 6. So output is 6 4 2.

Q217
5

Solution

When x=45 :

fun(45) => (45 % 6) % 2 = 1 (which is greater than 0) so function returns 45/9 => 5.

Q218
0

Solution

Q219
245

Solution

When fun1(23,222) inside while loop:

Iteration 1: x=201, y=44

Iteration 2: x=229,y=16

Iteration 3:x=245,y= 0 (y becomes 0 so loop stops)


So prints 245.

Q220
31

Solution

Initially x = 11 , y = 10 then z and y updated with 3. l=1 because both x and z are non zero. So output is 3 1.

Q221
12 9 6 3

Solution

In fun(108,3) :

108>1 so fun(36,6) called recursively

In fun(36,6) :

36>1 so fun(6,9) called recursively

In fun(6,9) :

6>1 so fun(0,12) called recursively

In fun(0,12) :

0>1 (false) so 12 gets printed and function call backtrack to fun(6,9) and prints 9. This process repeated until the function call backtrack

to fun(108,3) by printing 'y' values in each function call i.e. 12 9 6 3.

Q222
hat

Solution

String1= what

String2=e

String2 appended 4 times i.e whateeee. Then substring(1,4) => hat (from index 1 to 3)

Q223
62

Solution

Initially v = 5 ,a = 64 , r = 64>>5 => 2

Then r =64-2 => 62.

Q224
5

Solution

Null is considered as the end of the string.

Q225
17
Solution

Initially p = 0, q = 3, r = 14.If condition gets failed so 0+3+14=>17.

Q226
tratStsart

Solution

Concatenate String= "trastStart" ,

Reversed String => tratStsart

Q227
12 24 36 48 60 61

Solution

Each time i value increments by 12 and gets printed. Once it reaches 60 it gets printed in line 4 and executes else block and increment by

1 i.e 61. So output is 12 24 36 48 60 61.

Q228
38

Solution

Initially q=280 and p=0.

When i=1 , q=28 and p=30

When i=2 , q=2 and p=34

When i=3 , q=0 and p=36

When i=4 , q=0 and p=38. When i=5 loop terminates and prints 38.

Q229
72

Solution

Initially q=13, Loop starts from 1 i.e p=1.

r= 13%1=> 0

p=1+5=>6

q=6+0 =>6

Here p> 4 so loop terminates.

r=6/5=>1

Therefore 6 1 gets printed.

Q230
rrqrrqp

Solution

Initially a=pqr.
In fun(pqr) : len(pqr)>0 so fun(qr) called.

In fun(qr) : len(qr)>0 so fun(r) called.

In fun(r) : len(r)>0 so fun(empty string) called.

In fun(empty string) : len(qr)==0 so return nothin.

Then function call backtrack to fun(r) and again executes next line i.e. fun(r)

In fun(r) : len(r)>0 so fun(empty string) called.

In fun(empty string) : len(qr)==0 so return nothin.

Then function call backtrack to fun(r) and prints r. The same process repeated and prints rrqrrqp.

Q231
14

Solution

Initially pp=7,qq=7,

When rr=3, pp=14 (if block condition gets failed)

When rr=4, pp=21 (if block executes) and update pp=0.

When rr=5, pp=7 (if block condition gets failed)

When rr = 6 loop terminates and print 7+7 => 14

Q232
25

Solution

Here the value of pp updated to 15,qq updated to 4 and rr=6 after performing the bitwise operations. So output is 15+4+6 => 25.

Q233
10

Solution

Initially pp=1,qq=5,rr=10

rr=(9+1) and 1 => 1

rr=(1&3)^1 => 0

If block condition is true so pp=5+0+0=>5,qq=7&5=>5. Therefore 5+5+0=>10.

Q234
1

Solution

Initially pp=1,qq=4,rr=8. Inside loop, all the times only if block gets executed and update the qq value

i.e. When rr=3,qq=1

When rr=4,qq=0

When rr=5,qq=1
When rr=6,qq=0. Finally 1+0 => 1 gets printed.

Q235
23

Solution

For each iteration of m value gets updated. In the last iteration l=16(updated with max value in the array) and added with last value in the

array i.e 7. So output is 16+7=>23.

Q236
traversing an array

Solution

Here k value moves from LB to UB and printing the array values. So it is just traversing the array.

Q237
It will print three If x=9, y=8, z=6

Solution

When x=9, y=8, z=6, first if condition is true but second if condition gets failed so line 7 else block executes and print three.

Q238
39 32

Solution

Initially b=7,c=1

When j=2,i=1,then c= 2

When j=2,i=2,then c= 4

When j=3,i=1,then c= 8

When j=3,i=2,then c= 16

When j=3,i=3,then c= 32

Finally loop terminates and print b=7+32=>39 and c=32. So 39 32 gets printed.

Q239
5

Solution

Given pseudocode is used to find fibonacci series. So fibonacci series of 5 is 5.

Q240
0

Solution

Inside for loop b value gets updated with 24+18=>42. Then after c=5 there wont be any changers in the b. After the termination of for loop

42+2=>44%2=>0 gets printed.

Q241
3

Solution

Initially q=81,r=10.

Iteration1: 81 > 10 (true) so p=91,s=9,t=81,q=27

Iteration2: 27 > 10 (true) so p=37,s=3,t=9,q=9

Iteration3: 9 > 10 (false) So again checks 9>3 (true so 3 gets printed)

Q242
12 14 16 18 296

Solution

Initially a = 65,b= 0,c = 6,d= 0,i= 1. In while loop 65 > 6 (true), so b=12,d=12.Again it checks for 12<20 condition true. So b and d updated by

2 for each iterations until b> 20 by printing 12 14 16 18. These process repeated and at the end b= 296,d= 112 and c=66. So 296 gets

printed.

Q243
342

Solution

Above logic is used to reverse the number.

Q244
12 1

Solution

Inner while loop goes infinite loop because c value not get updated inside it.

Q245
100

Solution

Above pseudocode is used to find the max value in the array. So 100 gets printed.

Q246
4 18 31 43 23

Solution

Initially p = 15, q = 0, r = 60, s = 0

Iteration 1:

16%15 == 0 (true so update s =4 and q=15)

Inner loop:

4<50 (true) So print 4 and update s=18,q= 14

18<50 (true) So print 18 and update s=31,q= 13

31<50 (true) So print 31 and update s=43,q= 12


43<50(true) so prints 43 and update s=54,q=11

54<50 (False so loop terminates and update p=12)

Iteration 2:

60 %12 == (0) true (so update s =112 and q=23)

Inner loop:

112<50 (False so loop terminates and print q value i.e 23)

Q247
12

Solution

Initially a=3,b=4,c=5 first if condition gets failed so 3+4+5=12 gets printed.

Q248
13

Solution

Initially a=1

b=4

c=8

If condition gets failed so 1+4+8=> 13

Q249
1

Solution

Here if condition gets failed so m^2 => 1 gets printed.

Q250
56

Solution

Initially p= 5, q = 5, r = 10

When r=4,q= 7 then else block executes and update p= 9

When r=5,q= 11 then else block executes and update p= 14

When r=6,q= 16 then else block executes and update p= 20

When r=7,q= 22 then else block executes and update p= 27

When r=8 if block condition gets true and break the loop. So 27+29=56.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy