This Logic Building quiz will help you in building the foundation for mastering DSA. This quiz covers basic concepts of DSA which will test your thinking and reasoning skills.
Question 1
What will be the value of x
after the following code executes?
x = 5;
if (x > 3)
{ x = x + 2; }
else
{ x = x - 2; }
7
3
5
1
Question 2
Given the following pseudo code, what will be the output?
x = 4;
if (x > 5)
{ print("Greater") }
else if ( x<2 )
{ print("Lesser") }
else
{ print( " None") }
Lesser
Greater
None of the above.
None
Question 3
What will be the output of this switch-case pseudo code?
x = 4;
switch(x)
{ case 3:
print("One");
break;
case 9:
print("Two");
break;
case 4:
print("Three");
break;
default:
print("Other");
}
One
Two
Three
Other
Question 4
How many times will the following while
loop print "Hello"?
x = 5;
while(x > 1) {
print("Hello");
x = x - 1;
}
1
4
6
5
Question 5
Which of the following is the correct way to check if a variable x
is not equal to 10?
if(x != 10)
if(x ==! 10)
if(x <> 10)
if(x =! 10)
Question 6
What will be the value of x after executing the following pseudo codes
a)
x = 9;
x == 8;
b)
x = 9;
x = 7;
8, 9
8, 7
9 , 7
9, 9
Question 7
If an array has n elements then what will be the index of the last element of the array?
0
n
n + 1
n - 1
Question 8
What is the result of the following expression?
Here && is logical AND operator
( 5 < 8 ) && ( 3 > 1 )
True
False
None of the above
Undefioned
Question 9
What will be the value of z
after the following code?
x = 4;
y = 3;
z = x * y + 2;
10
14
12
9
Question 10
What will be the output of the following code?
( Where, || is a logical operator )
x = 5;
y = 10;
if(x > 3 || y < 5) {
print("Condition True");
} else {
print("Condition False");
}
Condition False
Condition True
Nothing
Error
There are 15 questions to complete.