Quiz-1a

Question 1

Time: 00:00:00
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%10
p=8^i
s=s+p*r
i++
n=n/10
End While
Return s;
End Function

27

27

187

187

87

87

120

120

Question 2

Time: 00:00:00
What will be the value of s if N=20?

Read N
Function sample(N)
s = 0
f = 1
i = 1
while i <= N:
f = f * i
s = s +(i / f)
i+=1
End while
return(s);
End Function

3.789456

3.789456

2.7182818284590455

2.7182818284590455

80.36741

80.36741

5.78888

5.78888

Question 3

Time: 00:00:00
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
n3 = n1 + n2
n1 = n2
n2 = n3
End While

112358

112358

12358

12358

123581321

123581321

12358132

12358132

Question 4

Time: 00:00:00
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;

3

3

4

4

2

2

1

1

Question 5

Time: 00:00:00
What will be the value of t if a = 65, b =123?

Read a,b
Function answer(a, b)
t = 0
while (b != 0):
t = t + a
b=b-1
End While
return t
End Function

6995

6995

7995

7995

8995

8995

None of the mentioned

None of the mentioned

Question 6

Time: 00:00:00
Find the error in Code to sort given array in ascending order:

Read size
Read a[1],a[2],…a[size]
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

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 4

Line 6

Line 6

Line 7

Line 7

No error

No error

Question 7

Time: 00:00:00
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()

2

2

15

15

17

17

-5

-5

Question 8

Time: 00:00:00
What will be the output of the following pseudocode for input a = 30, b = 60, C = 90?


Integer a, b, c, sum
Read a, b, c
Set sum = a + b + c
if ((sum EQUALS 180) and (a NOT EQUALS 0)
and (b NOT EQUALS 0) and (c NOT EQUALS 0))
Print " Success"
Otherwise Print "Fail"
End if

none of the mentioned

none of the mentioned

compilation error

compilation error

fail

fail

success

success

Question 9

Time: 00:00:00
What will be the output?

#include <iostream> 
using namespace std;
int main()
{
int a = 32, *ptr = &a;
char ch = 'A', &cho = ch;
cho += a;
*ptr += ch;
cout << a << ", " << ch << endl;
return 0;
}

129, a

129, a

32, a

32, a

32, A

32, A

129, A

129, A

Question 10

Time: 00:00:00
How many times the following loop be executed?

{
    …
   ch = ‘b’;
   while(ch >= ‘a’ && ch <= ‘z’)
   ch++;
}

error

error

25

25

26

26

1

1

null
null