0% found this document useful (0 votes)
43 views335 pages

Pseudocodes 2

The document presents various pseudocode snippets along with multiple-choice questions regarding their outputs. Each question requires analyzing the pseudocode to determine the correct answer from the provided options. The pseudocode covers a range of programming concepts including loops, conditionals, and function calls.

Uploaded by

Sai Kishore
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views335 pages

Pseudocodes 2

The document presents various pseudocode snippets along with multiple-choice questions regarding their outputs. Each question requires analyzing the pseudocode to determine the correct answer from the provided options. The pseudocode covers a range of programming concepts including loops, conditionals, and function calls.

Uploaded by

Sai Kishore
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 335

PSEUDOCODES

What will be the output of the following pseudocode?


Integer n,j,k,c,t,b,array[5]
Set n=6 c=1
Set array[5] = {1,2,3,5,6}
b=array[0]
For(each k from 1 to n-2)
b=b^array[k]
End for
For(each k from 2 to n)
c=c^k
End fro
c=c^b
Print c
• 17

• 5

• 6

• 4
What will be the outcome of the
following pseudo code for p=3 and q=4
int fun1(int p, int q)#3,4#f(6,2)#f(12,1)#f(24,0)

if(q EQUALS 0)

return 0

if(q mod 2 EQUALS 0)

return fun1(p + p, q/2) .#f(6,2)#f(12,1)

return fun1(p + p, q/2) + p#0+12=12

End function fun1()


A. None of the options

B. 7

C. 12

D. 8
• Option C
What will be the outcome of the
following pseudo code for a=2 and b=3
doSomething(Integer a, Integer b)

if(b EQUALS 1)

return 0

else

return a+ doSomething(a, b-1)


A. 3

B. 4

C. 2

D. 1
• Option b
What will be the outcome of the
following pseudo code
Integer a, n, sum, q, r

Set a=123, n=0, sum=0

Set q=a

while (q mod 10 NOT EQUALS 0)

n=n+1

q=q/10

End while

Print n

while (a greater than 0)

r=a mod 10

sum =sum + r

a =a/power(10, n- 1)

End while

Print sum
A. 3 2

B. 6 4

C. 6 5

D. 3 4
• Option D
What will be the outcome of the
following pseudo code
Integer a=5,b=8,c

if(a>8 OR b < 7)

c=a+b

else if(a + b > 9)

c=a-b

else

a=a+5

c=c-2

end if

a=a+b

Print a and c

b=b-5

[Note: OR — The logical Or operator returns the Boolean value if either or both operands are true and returns false
otherwise.]
A. None of the mentioned

B. 5 -3

C. 5 1

D. 13 -3
• Option D
What will be the outcome of the
following pseudo code
Set Integer Emp_no=101

Set Integer salary=0

while(Emp_no=501)

salary=salary+100

Display salary
A. Code executes successfully and value of salary
is displayed once.

B. Code executes successfully and nothing is


displayed.

C. Code executes successfully and value of salary


is displayed infinite number of times.

D. Compile time error.


• Option C
What will be the outcome of the
following pseudo code
Set Integer res=0

Do

- - res

Display res

res++
A. Code will run infinite number of times.

B. The program will not enter the loop.

C. Code will execute and value of res will be


displayed twice.

D. Code will execute and value of res will be


displayed once.
• Option A
What many times # will be displayed

for m=0 to 4 step 1 do


for n=0 to 4 step 1 do
display ‘#’
end-for
if(m==2) then do
break
end-if
end-for
A. 15

B. 1

C. 2

D. 8
• Option A
What will be the output of following
pseudocode
for i=0 to 4 step 1 do

if i==i++ + - -i then do

display i

end-if

end-for
A. 0

B. 3

C. 1

D. 2
• Option A
What will be the output of following
pseudocode
Set character c=‘7’
switch(c)
case ‘1’:display “One"
case ‘7’:display “Seven”
case ‘2’:display “Two”
default: display “Hello”
end-switch
A. SevenTwoHello

B. OneHello

C. SevenTwo

D. Seven
• Option A
What will be the output of following
pseudocode
Integer a,b,c
Set a=4,b=3,c=1
if (a>>(c-1)&&b<<(c+1))
a=a+c
else
b=a<<c
end if
print a-b+c
A. 3

B. 5

C. 8

D. None of these
• Option A
What will be the output of following
pseudocode
Integer a,p
Set a=5
a=a+1
a=a*2
a=a/2
p=a/5+6
print p
A. 0

B. 1

C. 2

D. 7
• Option D
What will be the output of following
pseudocode
Integer a,b,c
Set b=8,a=2
c=a^b
if(c^b)
b=0
End if
Print b
A. 3

B. 0

C. 10

D. 2
• Option B
What will be the output of following
pseudocode
Integer a,b,c
Set b=40,a=20,c=20
a=a+c
c=c+a
a=a+c
c=c+a
Print a+b+c
A. 40

B. 100

C. 300

D. None of these
• Option C
What will be the output of following
pseudocode
Integer a,b
Set a=1,b=1
a=(a^1)&1+(b^1)&1
Print a+b
A.1

B. 2

C. 0

D. None of these
• Option A
What will be the outcome of the
following pseudo code
• number=90

if(number>90 and number<95) then

display “data within the range”

else

display”data not within the range”

end-if
• Data within the range

• Data not within range

• Nothing will displayed


• Option b
The output of the following pseudo
code is _______
• set a=6,b=3,c=2
if(b>a&&a>c&&c>b)
b=a+1
else
a=b+1
end-if
print a+b+c
• 9
Which of the following will be printed by
the given pseudocode
• Integer i,j,k,n
set j=1,k=1
for(each i from 1 to 5)
print k
j=j+1
k=k+j
end-for
• 1 3 6 10 15

• 12345

• 4 6 8 10

• 11 2 3 5
• Option a
What will be the output of the following
pseudocode if a=10 and b=6
• Integer func(integer a,integer b)
integer temp
while(b)
temp=a MOD b
a=b
b=temp
end-while
return a
end function func()
• 2

• 4

• 3

• 1
• Option a
What will be the outcome of the
following pseudo code
• Integer i, j, k
Set k = 8
for(each i from 1 to 1)
for(each j from the value of i to 1)
print k+1
end for
end for
• 2

• 6

• 9

• 5
• Option c
What will be the outcome of the
following pseudo code
• Integer i
Set i = 3
do
print i + 3
i=i-1
while(i not equals 0)
end while
A) 6 6 6
B) 6 5 6
C) 5 5 5
D) 6 5 4
• Option d
What will be the outcome of the
following pseudo code
• Integer a

String str1

Set str1 = “goose”

a = stringLength(str1)

Print (a ^ 1)
A) 0
B) 4
C) 5
D) 3
• Option b
What will be the outcome of the
following pseudo code
• Integer a, b, c

Set a = 8, b = 51, c = 2

c = (a ^ c)^ (a)

b = b mod 4

Print a + b + c
A. 13
B. 17
C. 26
D. 16
• Option a
• Consider an array A = {1, 2, 4, 5, 6, 11, 12} anda
key which is equal to 10. How many
comparisons would be done to find the key
element in the array using the binary search?
A. 5
B. 1
C. 2
D. 3
• Option d
What will be the outcome of the
following pseudo code
• 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
A) 15
B) 7
C) 2
D) 0
• Option d
What will be the outcome of the
following pseudo code
• Integer arr[]={10, 20, 30, 40, 5}

Integer a, s

Set s = 0

Set a = arr[1] + arr[2]

Print a
A) 25
B) 5
C) 50
D) 40
• Option c
What will be the outcome of the
following pseudo code
• Integer a, b, c

Set b = 2, a = 2

c=a^b

Print c
A) 6
B) 4
C) 0
D) 2
• Option c
What will be the outcome of the
following pseudo code
• Integer x,y,z;

x=0

y=1

x=y=z=8

Print x
A) 0
B) 8
C) 1
D) None of the above
• Option b
What will be the outcome of the
following pseudo code
• Integer value, n

Set value = 1, n = 45

while(value less than equal to n)

value = value << 1

end loop

Print value
A) 64
B) 32
C) 45
D) None of the above
• Option a
What will be the outcome of the
following pseudo code
• Integer c, d
Set c = 15, d = 12
d = c – 1#14
Print c //line
c = d + (c – 2)
if(c < 40)
Goto line
end if
A) 14 26 38
B) 27 39
C) 15 27 39
D) None of the above
• Option c
Find the output of the following pseudo-
code if x= 4 and y=5:
• Integer fun(int x, int y)

if(x > 1)

fun(x – 2, y + 2)

end if

print y

End function fun()


A) 456
B) 765
C) 975
D) None of the above
• Option c
How many times will the print
statement be executed:
• Integer a, b, c
Set a = 8, b = 10, c = 6
If(a > c AND (b + c) > a)
Print a
end if
if(c > b OR (a + c) > b)
Print b
end if
if((b+c) MOD a EQUALS 0)
Print c
end if
A) 2
B) 3
C) 1
D) 0
• Option b
What will be the outcome of the
following pseudo code
• Integer x, y, z

Set x=24, y=8

x = x/y

z = y<<x

Print z
A) 1
B) 8
C) 0
D) 64
• Option d
What will be the outcome of the
following pseudo code
• Integer x, y, z, a

Set x = 2, y = 1, z = 5

a = (x AND y) OR (z + 1)

Print a
A) 5
B) 3
C) 2
D) 1
• Option d
What will be the outcome of the
following pseudo code
• Integer a=5, b=4, c=3
a=b+c
c=a–b
c=c+a
c=b+c
b=b+c
Print a, b, c
A) 7 14 7
B) 7 14 10
C) 7 8 14
D) 7 18 14
• Option d
What will be the output of the following pseudocode if n=5 and
elements of array are 24,20,60,100,200?
Integer fun(Integer a[], Integer n)
Integer x
if(n is equal to 1)
Return a[0]
else
x=fun(a,n-1)
If(x<a[n-1])
Return x
Else
Return a[n-1]
End Function fun()
• 60

• 20

• 24

• 100
What will be the output for the following pseudocode for
input pqr?
Fun(char a)
if(a[0] equals NULL)
return
end if
fun(a+1)
fun(a+1)
print(a[0])
End function Fun
• None of the mentioned

• rqppqr

• rrqrrqp

• ppqqrr
What will be the outcome of the
following pseudo code
• Integer a, b, c, d
Set b = 18, c = 12
a=b–c
for (each c from 1 to a – 1)
b = b + c + 12
b = b/5
d=b+a
end for
c=a+b+c
Print a b c
A) 539
B) 6 14 17
C) 6 4 14
D) 6 4 16
• Option d
What will be the outcome of the
following pseudo code
• Input m = 9, n = 6 ,
m=m+1;
n=n-1;
m=m+n
if (m > n)
print m
else
print n
A) 6
B) 5
C) 10
D) 15
• Option d
What will be the outcome of the
following pseudo code
• For input a = 8 & b = 9.
function (input a, input b)
If (a < b)
return function (b, a)
elseif (b != 0)
return (a + function (a, b - 1))
else
return 0
A) 56
B) 88
C) 72
D) 65
• Option c
What will be the outcome of the
following pseudo code
Input f = 6, g = 9 and set sum = 0
Integer n
if (g > f)
for (n = f; n < g; n = n + 1)
sum = sum + n
End for loop
else
print error message
print sum
A) 21
B) 15
C) 9
D) 6
• Option a
• Option c
def add1(n2):
if n2!=0:
return (n2+2)+add1(n2-1)
else:
return 3
def add(n1):
if n1!=0:
return add1(n1)+add(n1-1)
else:
return 0
print(add(5))
• 25
• 52
• 70
• 80
• Option d 28,21,15,10,6
What will be the output of the following pseudocode if
x=4?

defined in preprocessing as square ( x ) x * x

integer i

i = 64 / square ( x )

print i
• 64

• Garbage value

• 4

• 16
What will be the output of the following pseudocode if
a=3?

defined in preprocessing as square ( x ) x * x

print square(a+2)
• 11
What will be the output of the following pseudocode?

Input a[10] = {1,2,3,4,5,6,7,8,9,10}

print *a + 1 - * a + 3
• 4

• 100

• 44

• error
what will be 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
A. 1

B. 0

C. None

D. 2
#define PRODUCT(x) (x*x*x*x)

int x = 2;

int result = PRODUCT(x++);

printf("%d %d", x, result);


• 2 16

• 3 81

• 6 120

• 6 1296
Predict the output of the given pseudo code
if the value of n is 26 :
Read n
i=0
While n % 8 != 0
n=n+5
i++
end while
n=n+i
print n
• 16
• 32
• 10
• 62
• Option d
Predict the output of the given pseudo code
if the value of n is 35 :
Read n
i=0
While n % 10 != 0
n=n+3
i++
end while
n = n+i
print n
• 55
• 45
• 50
• 43
• Option a
Predict the output of the following
pseudocode
Integer x, y
Set x = 10, y = 8
Print ((x | 1) & (4) + (y ^ 1) & (1))
• 1
• 3
• 2
• 0
• Option a
What will be the output of the following
pseudocode?
Set x = 'a' * 10;
print x
• 97
• 970
• 10
• 200
• Option b
Predict the output of the given pseudocode
Set n = 14, sum = 0, i = 5
while i < n do
increase sum by 2 * i
increment i
end while
Write sum
• 117
• 130
• 162
• 140
• Option c
Predict how many times the value of res will
be displayed.
Set Integer res = 0
do
++res
display res
while(res <= 5)
End do-while
• The program will not enter the loop.

Code will run infinite number of times.

Code will execute and the value of res will be


displayed six times.

Code will execute and the value of res will be


displayed five times.
• Option c
What will be the output of the below
pseudocode?
Set Integer x = 0
do
++x
display x
x--
while(x >= -1)
End do-while
• The program will not enter the loop.

The code will run an infinite number of times.

Code will execute and the value of res will be


displayed once.

Code will execute and the value of res will be


displayed twice.
• Option b
Predict the output of the below pseudocode
Integer p, q
Set p = 11, q = 20
p = (p & 1) & (5) + (q ^ 1) & (5)
Print p
•3
•6
•2
•5
• Option b
Predict the output of the following
pseudocode
Integer p, q
Set p = 11, q = 20
p=q-p
Print p
•9
•3
•6
•2
• Option a
Given the pseudocode for performing
Binary search in an array of elements
sorted in ascending order. What operation
must be implemented in the 3rd so that the
execution of binary search is successful?
1.Middle element should be compared with
x.
2.If x and the middle element match, we
return the middle index.
3._ _ _ _ _ _ _ _ _ _ _
4.Else ( x is smaller than the middle
element) recur for the left half
• Else if x is greater than the middle element, then x can only lie
in the right half subarray after the middle element. So we recursively
search for the right
• Else if x is greater than the middle element, then x can only lie in the
left half subarray after the middle element. So we recursively search
for left
• Else if x equals the middle element, then we continue searching both
halves.
• Else if x is less than the middle element, then x can only lie in the right
half subarray after the middle element. So we recursively search for
the right
• Option a
Predict the output of the given pseudo code
if the value of the number is 6:
Read number
k=2
i=2
while i <= number:
k=k*i
i = i +1
end while
write k
• 1440
• 1340
• 1700
• 1560
• Option a
What is the output of the below
pseudocode?
Set value = ' ' * 10;
print value
• 100
• 320
• 10
• 200
• Option b
What happens when the below pseudocode
is executed?
Set Integer value = 10
Set Integer salary= 0
While (value = 10)
salary = salary + 100
display salary
END While
• Code executes successfully and the value
of salary is displayed once.
• Code executes successfully and nothing is
displayed.
• Code executes successfully the value of
salary is displayed infinite times.
• Compilation error.
• Option c
Count the number of " * " printed by the given
pseudo code when the input is 25.
Write "Please enter a number"
Read input
Repeat while input > 0
if( input > 0 and input <=12 )
Write *
else if ( input >12 and input <=24 )
Write **
else if ( input >24 and input< = 30 )
Write ***
input --
end if
End while
• 39
• 57
• 35
• 29
• Option a
Count the number of " # " printed.
For m = 0 to 14 do
For n = 0 to 14 do
display '#'
End-for
if(m = 5) then do
break
End-if
End-for
• 13
• 90
• 28
• 63
• Option b
Count the number of " # " printed.
For x = 0 to 8 do
For y = 0 to 6 do
display '#'
End-for
If(x == 2) then do
break
End-if
End-for
• 14
• 13
• 21
• 20
• Option c
What will be the output of the given pseudo
code if n = 10?
Read n
Initialize i to 5, sum to 0
while i < n do
increase sum by i
increment i
end while
Write sum
• 35
• 25
• 45
• 55
• Option a
• Option b
What will be the output if values of a=6,b=9?
• Integer func(integer a,integer b)
while(a!=b)
if a>b
return func(a-b,b)
else
return func(a,b-a)
end-while
return a
end function func()
• 3
• 6
• 9
• error
• Option a
What will be the output ?
• Read n
i=0 s=0 n = 127
Function Sample(int n)
while(n > 0):
r = n % 10
p = 8^i//(^-power)
s=s+p*r
i += 1
n = n / 10
return s: End Function
• 27
• 187
• 87
• 120
• Option c
Find the error in Code to sort given array in
ascending order:
• Read size
Read a[0],a[1],…a[size-1]
i=0
While(i<size)
j=i+1
While(j<size):
If a[i] < a[j] then
t= a[i]
a[i] = a[j]
a[j] = t
Find the error in Code to sort given array in
ascending order:
End If
j=j+1
End While
i=i+1
End While
i=0
While (i<size)
print a[i]
i=i+1
End While
• Line 4
• Line 6
• Line 7
• No error
• Option C
• function modify(a,b)
Integer c,d=2
c= a*d+ b
return c
function calculate()
Integer a = 5, b = 20, c
Integer d= 10
c = modify(a, b);
c = c+ d
print c
• 80
• 40
• 32
• 72
• Option b
What will be the output if limit = 6?
• Read limit
n1 = 0 n2= 1 n3=1
count = 1
while count <= limit:
count=count+1
print(n3,end = "")
n3 = n1 + n2
n1 = n2
n2 = n3
End While
A) 112358
B) 12358
C) 123581231
D) 123581321
• Option a
What will be the value of even_counter if number =
2630?
• Read number
Function divisible(number)
even_counter = 0
num_remainder = number
while (num_remainder):
digit = num_remainder % 10
if digit != 0 and number % digit == 0:
even_counter+=1 End If
num_remainder = num_remainder / 10 End While
return even_counter
A) 3
B) 4
C) 2
D) 1
• Option d
What will be the output of the following pseudo
code

• initialize char c

• set c= a

• print "%d",a
A) 64
B) 97
C) a
D) error
• Option b
What will be the output of the following
pseudo code for arr[]= 1,2,3,4,5
• initialize i,n

• intialize and array of size n


accept the values for the array

for 0 to n -1

arr[i] = arr[i]+arr[i+1]

end for

print the array elements


A) 35795
B) 3 5 7 9 11
C) 3 5 9 15 20
D) error
• Option a
What operation does the following pseudo
code performs
• Declare an array of string type variable called word
Declare a loopcounter

Store a string in the array word

for loopcounter = (length of the word) -1 to 0


loopcounter = loopcounter – 1

print arrayword[loopcounter]

endfor Algorithm end


A) it accepts string
B) it reverses string
C) it prints string in same order
D) none
• Option b
What will be the output?
• Integer a,b,c

a=1

b=3

c=(a++,b,a)

print c
A) 1
B) 2
C) 3
D) 4
• Option b
What will be the output?
• Integer x,y,z,a

set y=2

set x=(y=y*2)+(z=a=y)

print x
A) 8
B) 4
C) 2
D) 1
• Option a
What will be the output?
• Integer x=5
set b1=true
set b2=false
if((x==4)&&!b2)
print 1
print 2
if ((b2=true)&&b1)
print 3
A) 23
B) 12
C) 13
D) 2
• Option a
What will be the output?
• Integer x=0,y=20

while(x<10)

y=y-1

x=x+1

end while

print x and y
A) 20 10
B) 20 20
C) 10 10
D) 10 20
• Option c
What will be the output?
• Integer a[4]={4}

Integer i

for(each i from 0 to 2)

print a[i]
A) 004
B) 040
C) 400
D) 123
• Option c
What will be the output?
• Integer x=10

Integer y=15

if (!(!x)&&x)

print x

else

print y
A) 15
B) 10
C) 1
D) 0
• Option b
What will be the output?
• Integer a=10

if (!(!a)&&!a)

print !!a

else

print !a
A) 0
B) 10
C) 1
D) none
• Option a
What will be the output?
• Integer n

for(n=3;n!=0;n- -)

print n

n=n-1

end for
A) 31
B) 321
C) 3
D) infinite loop
• Option d
How many times loop will be executed?

• Ch=b;

while(ch>=a&&ch<=z)

ch++
A) 0
B) 25
C) 26
D) 1
• Option b
What is output?
• Integer x=5,y=10,z=15,a

a=x<y<z

print a
A) 0
B) 5
C) 10
D) 1
• Option d
What is output?
Integer a[5]={5,1,15,20,25}

Integer i,j,m

I=++a[1]

j=a[1]++

m=a[i++]

print i,j,m
A.2,1,5

B.1,2,5

C.3,2,15

D.2,3,20
• Option c
What is output?
integer n=1234
integer q,r,rn
set q=n and rn=0
while(q>0)
r=q mod 10
rn=rn+r^3(^ for power)
q=q/10
end while loop print rn
A.100

B.36

C.321

D.10
• Option a
What is output?
Integer x,y,z

x=y=z=1

z=++x||++y&&++z

print x y z
A.2 1 1

B.2 2 1

C.2 2 2

D.1 2 1
• Option a
What is output?
Integer a=10,x

x=a-- + ++a

print x
A.19

B.20

C.21

D.23
• Option b
How many times does the below for loop
repeated?
for (i=5;i>=1;i--)

for(j=1;j<=i;j++)

print y
A.15

B.11

C.10

D.13
• Option a
What will be the output of the given pseudocode?
Integer a,b,c
Set a=5,b=3,c=6
b=(c&b)+b
for (each c from 2 to 4)
b=(5&6)^a
End for
print a+b
Select the appropriate answer from the given choices
24.0

11.0

-12.0

6.0
6.0
What will be the output of the given pseudocode?
Integer a,b,c
Set a=5,b=7,c=5
b=(1^4)+b
if((c&b&a)<(a&c))
c=a+a
End if
print a+b+c
27
What will be the output of the given pseudocode for
a=2,b=7 and c=6
1.Integer funn (Integer a, Integer b, Integer c)
2 b=(c^8)+c
3 for(each c from 4 to 7)
4 b=(c+11)&b
5 a=11&a
6 End for
7 return a+b
2
What will be the output of the following pseudocode for
a=0,b=4,c=6?
Integer funn(Integer a,Integer b,Integer c)
a=c^a
if (c^a^b)<(a+b+c)
b=(2+5)&a
b=(b&8)^b
end if
a=6^a
return a+b+c
12

17

15

9
A
What will be the output of the following
pseudocode for i=140?
Integer fun(int i)
if i%2!=0
return i
else
return fun(fun(i=1))
End function fun()
1

Error
A
What will be the output of the given pseudocode
for a=3, b=9
Integer funn(Integer a,Integer b)
if ((b-a)>(a&b) &&(b^a)>(6-b))
a=1+2+a
a=1+3+b
b=a+3
return funn(b,b)+b
end if
return a-1
40

37

31

28
C
What will be the output of the given pseudocode
for a=8,b=2?
Integer funn(Integer a,Integer b)
if b<a && 4>b
b=1+1+a
a=2+1+b
return funn(a,b)
end if
b=b+2+b
return a+b
43

35

38

31
B
What will be the output of the given pseudocode
for a=6,b=7?
Integer funn(Integer a,Integer b)
if b>a && a>3
a=b+1+a
b=1+3+a
return a-funn(b,b)
end if
return b-1
-16

-3

14
C
What will be the output of the given pseudocode for
a=8,b=7,c=4?
Integer funn(Integer a,Integer b)

a=b+b&c

for each c from 5 to 7

b=3+c

b=4+7+b

a=(b&c)+c

end for

c=a+c

return a+b
37

23

16

33
D
What will be the output of the given pseudocode
for a=7,b=8?
Integer funn(Integer a,Integer b)
if (b&a)>(a-b) && a>4
a=3+b+b
a=2+b+a
return a-funn(a,b)+funn(a+1,b)
end if
a=a+1
return a-1
30

29

31

28
A
What will be the output of the given pseudocode
for a=1,b=1?
Integer funn(Integer a,Integer b)
if a<3 && (a&b)<(b+a)
b=a+2
b=b+1
return b-funn(b,b)
end if
b=b+3
return a+b
-12

-7

-2

-5
B
Keep the statement language ______________ while
writing a pseudo code.
• Dependent

• Independent

• Case sensitive

• capitalized
• Option b
Capitalize initial keyword – This is a rule while writing a
pseudo code.
• True

• False
• true
Which of the following is not a keyword?
• read

• Write

• Start

• End if
• Option c
______________ is used to show hierarchy in a
pseudo code.
• indentation
• Curly braces
• Semicolon
• Round braces
• Option a
The statement that tells the computer to get a value from
an input device and store it in a memory location.
• read

• write

• READ

• WRITE
• Option c
_____________ are identified by their addresses, we give
them names (field names / variable names) using words.
• Memory variables
• Memory locations
• Memory addresses
• Data variables
• Option b
• ____________ begins with lower case letters.
• Keywords
• Variables
• Tokens
• Functions
• Option b
• Another notation for exponentiation.
• *
• **
• ***
• *^
• Option b
• A symbol used for grouping.
• ()
• {}
• []
• ““
• Option a
• A statement used to close the IF block.
• ELSE
• ELSEIF
• END
• ENDIF
• Option d
• What does the following piece of code do?
• public void func (Tree root)
{
func (root.left ());
func (root.right ());
System.out.println (root.data ());
}
• Predorder traversal

• Postorder traversal

• Inorder traversal

• Level order travesal


• Option b
• What will be the output of the following pseudocode?

Integer a

Set float b=7.0

Switch(a=b+1)

case 8: display “pseudocode”

break

default: display “pseudo”

End switch
• Infinite loop

• Error

• Pseudo

• Pseudocode
• Option d
• What will be the output of the following pseudocode?

Set Integer x=7

Set float y=7.0

If x equals y then

display “they are equal”

else

display “they are unequal”

End if
• They are unequal

• Not answered

• They are equal

• error
• Option c
• How many iterations will the following pseudocode make
to find key with value 37?
Integer key
Set Integer array=[27,17,47,37,67]
for ele=0 to 4 step 1 do
if array[ele] equals key
display “found”
end-if
End for
• 5

• 3

• error

• 4
• Option d
• What will be the output of the following
pseudocode?

Set integer array=[3,7,18,9,5]

Set integer result=(++array[3])

display result
• 9

• 10

• 18

• 19
• Option b
• What will be the output of the following
pseudocode?

Set integer y=2

Set integer z=4

display ((y or z) and (z or y))


• 2

• 4

• 0

• 1
• Option d
• What will be the output of the following pseudocode if
n=10?
Read n
Initialize i to 5//i=5
While i<n, do://5<10-t
increase sum by i//sum=sum+i//0+5=5
increment i//6
End while
Write sum
• 35.0

• 25.0

• 45.0

• 55.0
• Option a
• Problem statement: find the closest pair of points in
an array of distinct points
• Assume that you solve this problem by comparing all
pairs of points. What will be the complexity of this
approach?
• O(n*2)
• O(n)
• O(n log n)
• Cannot be determined
• Option a

You might also like