Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

New test

First and last name

Question 1/10
What is the purpose of using logical operators in programming?
A. To make the code look neater
B. To solve complicated logics that ultimately boil down to only two answers.
C. To make the code more difficult to understand
D. To increase the time it takes to execute the program

Question 2/10
What is the limitation of conditional operators?
A. They can only be used in if-else statements.
B. They can only contain one C statement after ? or :
C. They can only be used in for loops.
D. They can only be used with unary operators.

Question 3/10
Which is used more frequently in serious C programming, conditional operators or if-else statements?
A. Conditional operators
B. if-else statements
C. Both are used equally
D. None of the above

Question 4/10
What is the purpose of the NOT operator?
A. To add a condition to a statement
B. To reverse the logical value of a single variable
C. To combine two conditions
D. To set a variable to a specific value

Question 5/10
What is the else if clause used for in C programming?
A. To allow multiple conditions to be combined in an if statement.
B. To perform arithmetic operations.
C. To reduce indentation of statements.
D. To create a ladder of conditions to be checked.

Question 6/10
What are the conditional operators?
A. && and ||
B. > and <
C. ? and :
D. == and !=

1
New test

Question 7/10
What does the NOT operator do?
A. It reverses the result of the expression it operates on.
B. It multiplies the result of the expression it operates on by -1.
C. It adds 1 to the result of the expression it operates on.
D. It divides the result of the expression it operates on by 2.

Question 8/10
What are the two situations when logical operators are useful in programming?
A. When we want to write programs for complicated logics and when we want to check in which range does
a value fall.
B. When we want to make the program run slower and when we want to make the code look more
complicated.
C. When we want to test several conditions and when we want to combine the usage of if— else if—else
and logical operators.
D. When after testing several conditions, the outcome is only one of the two answers and when we want to
check in which range does a value fall.

Question 9/10
Under what condition can conditional operators be used as an alternative to if-else statements?
A. If there is only one statement in the if block.
B. If there is only one statement in the else block.
C. If there is only one statement in both the if and else blocks.
D. If there are multiple statements in both the if and else blocks.

Question 10/10
What is the advantage of using logical operators in programming?
A. The program doesn't creep to the right even with several conditions.
B. Matching of opening and closing braces becomes easier.
C. Matching of if statements with their corresponding elses becomes easier.
D. All of the above.

You might also like