Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Decision control structure MCQs

1. Which of the following is a decision control structure?
a) while loop
b) for loop
c) if statement
d) do-while loop

Answer: c) if statement
Explanation: The if statement is used for decision-making in programming, allowing the execution of a block of code based on a condition.

2. What is the purpose of using logical operators in programming?
a) To perform mathematical calculations
b) To compare two variables
c) To combine multiple conditions
d) To assign values to variables

Answer: c) To combine multiple conditions
Explanation: Logical operators (such as AND, OR, NOT) are used to combine multiple conditions to form complex conditional expressions in programming.

3. Which operator is used to check if two values are equal in C programming?
a) ==
b) =
c) <= d) >=

Answer: a) ==
Explanation: The == operator is used to check if two values are equal in C programming. It returns true if the values are equal, otherwise false.

4. What is the purpose of the increment (++) and decrement (–) operators?
a) To multiply and divide values
b) To add or subtract 1 from a variable
c) To perform bitwise operations
d) To check for equality

Answer: b) To add or subtract 1 from a variable
Explanation: The increment (++) operator adds 1 to the variable, while the decrement (–) operator subtracts 1 from the variable.

5. Which loop executes the code block at least once, even if the condition is false initially?
a) for loop
b) while loop
c) do-while loop
d) odd loop

Answer: c) do-while loop
Explanation: The do-while loop executes the code block once and then checks the condition. If the condition is true, the loop continues to execute.

6. What is the purpose of the break statement in programming?
a) To terminate the loop and exit the program
b) To skip the current iteration of the loop
c) To exit the switch statement and continue with the next code block
d) To increment the loop counter

Answer: a) To terminate the loop and exit the program
Explanation: The break statement is used to prematurely terminate a loop and exit the loop’s block of code.

7. Which operator is used to access the address of a variable in C programming?
a) &
b) *
c) .
d) >

Answer: a) &
Explanation: The & operator is used to access the address of a variable in C programming, commonly used with pointers.

8. What does the sizeof operator return in C programming?
a) Size of a variable in bytes
b) Size of a function in bytes
c) Size of a loop iteration
d) Size of a conditional statement

Answer: a) Size of a variable in bytes
Explanation: The sizeof operator returns the size of a variable or data type in bytes.

9. Which loop structure allows for the execution of a block of code a specific number of times?
a) while loop
b) for loop
c) do-while loop
d) odd loop

Answer: b) for loop
Explanation: The for loop in programming allows for the execution of a block of code a specific number of times, controlled by a loop counter.

10. Which operator is used to perform bitwise AND operation in C programming?
a) &&
b) ||
c) &
d) |

Answer: c) &
Explanation: The & operator in C programming is used to perform bitwise AND operation between two operands.

11. What does the continue statement do in a loop?
a) Exits the loop
b) Skips the remaining code in the loop and proceeds to the next iteration
c) Breaks the loop and exits the program
d) Resets the loop counter

Answer: b) Skips the remaining code in the loop and proceeds to the next iteration
Explanation: The continue statement is used to skip the remaining code in the current iteration of a loop and proceed to the next iteration.

12. Which control structure is used to select one of many code blocks to execute based on a specified condition?
a) for loop
b) switch statement
c) if-else statement
d) while loop

Answer: b) switch statement
Explanation: The switch statement is used to select one of many code blocks to execute based on the value of a variable or expression.

13. Which loop structure is best suited for situations where the number of iterations is not known beforehand?
a) for loop
b) while loop
c) do-while loop
d) odd loop

Answer: b) while loop
Explanation: The while loop is best suited for situations where the number of iterations is not known beforehand, as it continues to execute until the condition becomes false.

14. What is the purpose of the goto statement in programming?
a) To exit the loop
b) To jump to a specified label within the code
c) To increment the loop counter
d) To perform bitwise operations

Answer: b) To jump to a specified label within the code
Explanation: The goto statement is used to transfer control to a specified label within the code, which can be located anywhere in the program.

15. Which special operator is used to access members of a structure or union in C programming?
a) *
b) .
c) &
d) >

Answer: b) .
Explanation: The . operator is used to access members of a structure or union in C programming, also known as the dot operator.

Leave a Comment