# 2nd year Computer Chapter 11 Decision Constructs

## 2nd year Computer Chapter 11 Decision Constructs Question And Answer

### Short An Simple Question An Answer

Q 1. What is a Control Structure?

Ans. A control structure is a statement that manages the flow of execution in a program or function, combining individual instructions into a single logical unit with one entry and one exit point. It’s essential for implementing program logic and includes three types:

• Sequence structure
• Selection structure
• Repetition structure

Q 2. What is a Sequence Structure?

Ans. In a sequence structure, program instructions execute one after another in the order they are written. This structure represents the default flow of a program, starting from the first instruction and proceeding sequentially.

Q 3. What is a Selection Structure?

Ans. A selection structure divides program instructions into two or more groups, with one group selected for execution based on the evaluation of a specific condition.

Q 4. What is a Repetition Structure?

Ans. A repetition structure, also known as an iteration or loop structure, is used to repeatedly execute a statement or set of statements as long as a given condition remains true. This structure is employed for performing the same or similar tasks and includes three basic loop types in C language:

• While loop
• Do-while loop
• For loop

Q 5. What is an IF statement?

Ans. “IF” is a keyword in C language, and the “IF” statement is the simplest form of a selection structure. It’s used to execute or skip a statement or set of statements after testing a condition. If the condition evaluates as true, the statements after the “IF” statement are executed, while they are skipped if the condition is false.

Q 6. What is a Compound Statement?

Ans. A set of statements enclosed within curly brackets is known as a compound statement or block of code.

Q 7. What is an if-else statement?

Ans. When a two-way decision is needed, the “if-else” statement is used. It evaluates a condition and executes one of two code blocks, skipping the other. Both code blocks cannot be executed or skipped.

Q 8. What is an if-else-if statement?

Ans. The “if-else-if” statement is used when multiple compound statements are available, and one needs to be chosen. It allows for choosing one from multiple compound statements based on various conditions.

Q 9. What is a Conditional Operator?

Ans. The conditional operator is used as an extension of a simple “if-else” statement to make a two-way decision. It uses the syntax “(Condition) ? Statement 1 : Statement 2” to select between two statements based on the condition’s evaluation.

Q 10. What is a Switch Statement?
Ans
. A switch statement is an alternative to the if-else-if statement and is another type of conditional statement. It’s used when there’s a need to execute a block of statements from multiple blocks based on a specific expression’s value. The general syntax of a switch statement is as follows:Switch (expression) {
case constant-expression:
statement(s);
break;
case constant-expression:
statement(s);
break;
default:
statement(s);
}
Q 11. What is a Nested if Statement?
Ans
. A nested if statement occurs when an “if” statement is used within another “if” statement. It involves placing one if statement inside another. The general syntax of a nested if statement is as follows:

If (Condition 1) {
If (Condition 2) {
Statement;
}
}
Q 12. What is a Break Statement?
Ans
. The “break” statement is a keyword used to exit the current loop or switch statement. When executed in a switch statement, it transfers the flow of control outside of the code block, allowing the program to continue with the first instruction after the switch block.

Check Also
Close