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
• 1 2 3 4 5
• 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) 4 5 6
B) 7 6 5
C) 9 7 5
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) 5 3 9
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) 3 5 7 9 5
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) 0 0 4
B) 0 4 0
C) 4 0 0
D) 1 2 3
• 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) 3 1
B) 3 2 1
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
2
3
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
6
-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

pseudocodes for interview preparation 2.pptx

  • 1.
  • 2.
    What will bethe 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
  • 3.
  • 4.
    What will bethe 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()
  • 5.
    A. None ofthe options B. 7 C. 12 D. 8
  • 6.
  • 7.
    What will bethe 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)
  • 8.
  • 9.
  • 10.
    What will bethe 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
  • 11.
    A. 3 2 B.6 4 C. 6 5 D. 3 4
  • 12.
  • 13.
    What will bethe 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.]
  • 14.
    A. None ofthe mentioned B. 5 -3 C. 5 1 D. 13 -3
  • 15.
  • 16.
    What will bethe outcome of the following pseudo code Set Integer Emp_no=101 Set Integer salary=0 while(Emp_no=501) salary=salary+100 Display salary
  • 17.
    A. Code executessuccessfully 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.
  • 18.
  • 19.
    What will bethe outcome of the following pseudo code Set Integer res=0 Do - - res Display res res++
  • 20.
    A. Code willrun 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.
  • 21.
  • 22.
    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
  • 23.
  • 24.
  • 25.
    What will bethe output of following pseudocode for i=0 to 4 step 1 do if i==i++ + - -i then do display i end-if end-for
  • 26.
  • 27.
  • 28.
    What will bethe 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
  • 29.
  • 30.
  • 31.
    What will bethe 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
  • 32.
    A. 3 B. 5 C.8 D. None of these
  • 33.
  • 34.
    What will bethe 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
  • 35.
  • 36.
  • 37.
    What will bethe 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
  • 38.
    A. 3 B. 0 C.10 D. 2
  • 39.
  • 40.
    What will bethe 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
  • 41.
    A. 40 B. 100 C.300 D. None of these
  • 42.
  • 43.
    What will bethe output of following pseudocode Integer a,b Set a=1,b=1 a=(a^1)&1+(b^1)&1 Print a+b
  • 44.
    A.1 B. 2 C. 0 D.None of these
  • 45.
  • 46.
    What will bethe 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
  • 47.
    • Data withinthe range • Data not within range • Nothing will displayed
  • 48.
  • 49.
    The output ofthe 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
  • 50.
  • 51.
    Which of thefollowing 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
  • 52.
    • 1 36 10 15 • 1 2 3 4 5 • 4 6 8 10 • 11 2 3 5
  • 53.
  • 54.
    What will bethe 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()
  • 55.
  • 56.
  • 57.
    What will bethe 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
  • 58.
  • 59.
  • 60.
    What will bethe 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
  • 61.
    A) 6 66 B) 6 5 6 C) 5 5 5 D) 6 5 4
  • 62.
  • 63.
    What will bethe outcome of the following pseudo code • Integer a String str1 Set str1 = “goose” a = stringLength(str1) Print (a ^ 1)
  • 64.
  • 65.
  • 66.
    What will bethe 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
  • 67.
  • 68.
  • 69.
    • Consider anarray 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?
  • 70.
  • 71.
  • 72.
    What will bethe 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
  • 73.
  • 74.
  • 75.
    What will bethe 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
  • 76.
    A) 25 B) 5 C)50 D) 40
  • 77.
  • 78.
    What will bethe outcome of the following pseudo code • Integer a, b, c Set b = 2, a = 2 c = a ^ b Print c
  • 79.
  • 80.
  • 81.
    What will bethe outcome of the following pseudo code • Integer x,y,z; x=0 y=1 x = y = z = 8 Print x
  • 82.
    A) 0 B) 8 C)1 D) None of the above
  • 83.
  • 84.
    What will bethe 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
  • 85.
    A) 64 B) 32 C)45 D) None of the above
  • 86.
  • 87.
    What will bethe 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
  • 88.
    A) 14 2638 B) 27 39 C) 15 27 39 D) None of the above
  • 89.
  • 90.
    Find the outputof 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()
  • 91.
    A) 4 56 B) 7 6 5 C) 9 7 5 D) None of the above
  • 92.
  • 93.
    How many timeswill 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
  • 94.
  • 95.
  • 96.
    What will bethe outcome of the following pseudo code • Integer x, y, z Set x=24, y=8 x = x/y z = y<<x Print z
  • 97.
    A) 1 B) 8 C)0 D) 64
  • 98.
  • 99.
    What will bethe 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
  • 100.
  • 101.
  • 102.
    What will bethe 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
  • 103.
    A) 7 147 B) 7 14 10 C) 7 8 14 D) 7 18 14
  • 104.
  • 105.
    What will bethe 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()
  • 106.
  • 107.
    What will bethe 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
  • 108.
    • None ofthe mentioned • rqppqr • rrqrrqp • ppqqrr
  • 109.
    What will bethe 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
  • 110.
    A) 5 39 B) 6 14 17 C) 6 4 14 D) 6 4 16
  • 111.
  • 112.
    What will bethe 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
  • 113.
    A) 6 B) 5 C)10 D) 15
  • 114.
  • 115.
    What will bethe 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
  • 116.
  • 117.
  • 118.
    What will bethe 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
  • 119.
  • 120.
  • 122.
  • 123.
    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))
  • 124.
  • 125.
    • Option d28,21,15,10,6
  • 126.
    What will bethe output of the following pseudocode if x=4? defined in preprocessing as square ( x ) x * x integer i i = 64 / square ( x ) print i
  • 127.
    • 64 • Garbagevalue • 4 • 16
  • 128.
    What will bethe output of the following pseudocode if a=3? defined in preprocessing as square ( x ) x * x print square(a+2)
  • 129.
  • 130.
    What will bethe output of the following pseudocode? Input a[10] = {1,2,3,4,5,6,7,8,9,10} print *a + 1 - * a + 3
  • 131.
    • 4 • 100 •44 • error
  • 132.
    what will bethe 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
  • 133.
    A. 1 B. 0 C.None D. 2
  • 134.
    #define PRODUCT(x) (x*x*x*x) intx = 2; int result = PRODUCT(x++); printf("%d %d", x, result);
  • 135.
    • 2 16 •3 81 • 6 120 • 6 1296
  • 136.
    Predict the outputof 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
  • 137.
  • 138.
  • 139.
    Predict the outputof 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
  • 140.
  • 141.
  • 142.
    Predict the outputof the following pseudocode Integer x, y Set x = 10, y = 8 Print ((x | 1) & (4) + (y ^ 1) & (1))
  • 143.
  • 144.
  • 145.
    What will bethe output of the following pseudocode? Set x = 'a' * 10; print x
  • 146.
  • 147.
  • 148.
    Predict the outputof 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
  • 149.
  • 150.
  • 151.
    Predict how manytimes the value of res will be displayed. Set Integer res = 0 do ++res display res while(res <= 5) End do-while
  • 152.
    • The programwill 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.
  • 153.
  • 154.
    What will bethe output of the below pseudocode? Set Integer x = 0 do ++x display x x-- while(x >= -1) End do-while
  • 155.
    • The programwill 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.
  • 156.
  • 157.
    Predict the outputof the below pseudocode Integer p, q Set p = 11, q = 20 p = (p & 1) & (5) + (q ^ 1) & (5) Print p
  • 158.
  • 159.
  • 160.
    Predict the outputof the following pseudocode Integer p, q Set p = 11, q = 20 p = q - p Print p
  • 161.
  • 162.
  • 163.
    Given the pseudocodefor 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
  • 164.
    • Else ifx 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
  • 165.
  • 166.
    Predict the outputof 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
  • 167.
    • 1440 • 1340 •1700 • 1560
  • 168.
  • 169.
    What is theoutput of the below pseudocode? Set value = ' ' * 10; print value
  • 170.
  • 171.
  • 172.
    What happens whenthe below pseudocode is executed? Set Integer value = 10 Set Integer salary= 0 While (value = 10) salary = salary + 100 display salary END While
  • 173.
    • Code executessuccessfully 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.
  • 174.
  • 175.
    Count the numberof " * " 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
  • 176.
  • 177.
  • 178.
    Count the numberof " # " 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
  • 179.
  • 180.
  • 181.
    Count the numberof " # " 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
  • 182.
  • 183.
  • 184.
    What will bethe 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
  • 185.
  • 186.
  • 188.
  • 189.
    What will bethe 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()
  • 190.
    • 3 • 6 •9 • error
  • 191.
  • 192.
    What will bethe 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
  • 193.
  • 194.
  • 195.
    Find the errorin 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
  • 196.
    Find the errorin 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
  • 197.
    • Line 4 •Line 6 • Line 7 • No error
  • 198.
  • 199.
    • function modify(a,b) Integerc,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
  • 200.
  • 201.
  • 202.
    What will bethe 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
  • 203.
    A) 112358 B) 12358 C)123581231 D) 123581321
  • 204.
  • 205.
    What will bethe 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
  • 206.
  • 207.
  • 208.
    What will bethe output of the following pseudo code • initialize char c • set c= a • print "%d",a
  • 209.
    A) 64 B) 97 C)a D) error
  • 210.
  • 211.
    What will bethe 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
  • 212.
    A) 3 57 9 5 B) 3 5 7 9 11 C) 3 5 9 15 20 D) error
  • 213.
  • 214.
    What operation doesthe 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
  • 215.
    A) it acceptsstring B) it reverses string C) it prints string in same order D) none
  • 216.
  • 217.
    What will bethe output? • Integer a,b,c a=1 b=3 c=(a++,b,a) print c
  • 218.
  • 219.
  • 220.
    What will bethe output? • Integer x,y,z,a set y=2 set x=(y=y*2)+(z=a=y) print x
  • 221.
  • 222.
  • 223.
    What will bethe output? • Integer x=5 set b1=true set b2=false if((x==4)&&!b2) print 1 print 2 if ((b2=true)&&b1) print 3
  • 224.
  • 225.
  • 226.
    What will bethe output? • Integer x=0,y=20 while(x<10) y=y-1 x=x+1 end while print x and y
  • 227.
    A) 20 10 B)20 20 C) 10 10 D) 10 20
  • 228.
  • 229.
    What will bethe output? • Integer a[4]={4} Integer i for(each i from 0 to 2) print a[i]
  • 230.
    A) 0 04 B) 0 4 0 C) 4 0 0 D) 1 2 3
  • 231.
  • 232.
    What will bethe output? • Integer x=10 Integer y=15 if (!(!x)&&x) print x else print y
  • 233.
  • 234.
  • 235.
    What will bethe output? • Integer a=10 if (!(!a)&&!a) print !!a else print !a
  • 236.
    A) 0 B) 10 C)1 D) none
  • 237.
  • 238.
    What will bethe output? • Integer n for(n=3;n!=0;n- -) print n n=n-1 end for
  • 239.
    A) 3 1 B)3 2 1 C) 3 D) infinite loop
  • 240.
  • 241.
    How many timesloop will be executed? • Ch=b; while(ch>=a&&ch<=z) ch++
  • 242.
  • 243.
  • 244.
    What is output? •Integer x=5,y=10,z=15,a a=x<y<z print a
  • 245.
    A) 0 B) 5 C)10 D) 1
  • 246.
  • 247.
    What is output? Integera[5]={5,1,15,20,25} Integer i,j,m I=++a[1] j=a[1]++ m=a[i++] print i,j,m
  • 248.
  • 249.
  • 250.
    What is output? integern=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
  • 251.
  • 252.
  • 253.
    What is output? Integerx,y,z x=y=z=1 z=++x||++y&&++z print x y z
  • 254.
    A.2 1 1 B.22 1 C.2 2 2 D.1 2 1
  • 255.
  • 256.
    What is output? Integera=10,x x=a-- + ++a print x
  • 257.
  • 258.
  • 259.
    How many timesdoes the below for loop repeated? for (i=5;i>=1;i--) for(j=1;j<=i;j++) print y
  • 260.
  • 261.
  • 262.
    What will bethe 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
  • 263.
  • 264.
  • 265.
    What will bethe 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
  • 266.
  • 267.
    What will bethe 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
  • 268.
  • 269.
    What will bethe 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
  • 270.
  • 271.
  • 272.
    What will bethe 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()
  • 273.
  • 274.
  • 275.
    What will bethe 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
  • 276.
  • 277.
  • 278.
    What will bethe 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
  • 279.
  • 280.
  • 281.
    What will bethe 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
  • 282.
  • 283.
  • 284.
    What will bethe 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
  • 285.
  • 286.
  • 287.
    What will bethe 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
  • 288.
  • 289.
  • 290.
    What will bethe 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
  • 291.
  • 292.
  • 293.
    Keep the statementlanguage ______________ while writing a pseudo code. • Dependent • Independent • Case sensitive • capitalized
  • 294.
  • 295.
    Capitalize initial keyword– This is a rule while writing a pseudo code. • True • False
  • 296.
  • 297.
    Which of thefollowing is not a keyword? • read • Write • Start • End if
  • 298.
  • 299.
    ______________ is usedto show hierarchy in a pseudo code. • indentation • Curly braces • Semicolon • Round braces
  • 300.
  • 301.
    The statement thattells the computer to get a value from an input device and store it in a memory location. • read • write • READ • WRITE
  • 302.
  • 303.
    _____________ are identifiedby their addresses, we give them names (field names / variable names) using words. • Memory variables • Memory locations • Memory addresses • Data variables
  • 304.
  • 305.
    • ____________ beginswith lower case letters. • Keywords • Variables • Tokens • Functions
  • 306.
  • 307.
    • Another notationfor exponentiation. • * • ** • *** • *^
  • 308.
  • 309.
    • A symbolused for grouping. • () • {} • [] • “ “
  • 310.
  • 311.
    • A statementused to close the IF block. • ELSE • ELSEIF • END • ENDIF
  • 312.
  • 313.
    • What doesthe following piece of code do? • public void func (Tree root) { func (root.left ()); func (root.right ()); System.out.println (root.data ()); }
  • 314.
    • Predorder traversal •Postorder traversal • Inorder traversal • Level order travesal
  • 315.
  • 316.
    • What willbe 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
  • 317.
    • Infinite loop •Error • Pseudo • Pseudocode
  • 318.
  • 319.
    • What willbe 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
  • 320.
    • They areunequal • Not answered • They are equal • error
  • 321.
  • 322.
    • How manyiterations 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
  • 323.
    • 5 • 3 •error • 4
  • 324.
  • 325.
    • What willbe the output of the following pseudocode? Set integer array=[3,7,18,9,5] Set integer result=(++array[3]) display result
  • 326.
  • 327.
  • 328.
    • What willbe the output of the following pseudocode? Set integer y=2 Set integer z=4 display ((y or z) and (z or y))
  • 329.
  • 330.
  • 331.
    • What willbe 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
  • 332.
    • 35.0 • 25.0 •45.0 • 55.0
  • 333.
  • 334.
    • 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
  • 335.