Questions 1: What will be the value of s if n = 127 ?
Read n
i=0,s=0
Function Sample(int n)
while(n>0)
r=n%l0
p=8^i
s=s+p*r
i++
n=n/10
End While
Return s;
End Function
Answer: c
Questions 2: What will be the output of the following pseudo code?
Integer n
for (n = 3; n != 0; n–)
Print n
n = n-1
end for
Answer: d
Questions 3: What will be the output 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
Answer: c
Questions 4: 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= even_counter+1
End If
num_remainder= num_remainder / 10
End While
return even_counter
Answer: d
Questions 5: What will be the value of t if a = 56 , b = 876?
Read a,b
Function mul(a, b)
t = 0
while (b != 0)
t = t + a
b=b-1
End While
return t
End Function
Answer: b
Questions 6: Consider the following piece of code. What will be the space required for this code?
int sum(int A[], int n)
{
int sum = 0, i;
for(i = 0; i < n; i++)
sum = sum + A[i];
return sum;
}
// sizeof(int) = 2 bytes
Answer: a
Questions 7: How many times the following loop be executed?
{
…
ch = ‘b’
while(ch >= ‘a’ && ch <= ‘z’)
ch++
}
Answer: b
Questions 8: What will be the output 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
Answer: d
Questions 9: What will be the output 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
Answer: a
Questions 10: What will be the output of the following pseudo code?
Integer a, b
Set a = 1, b = 20
If ( ( a + b ) < ( b >> 1 ) )
a = a >> 1
End if
a = a + b
Print a + b
Answer: c