2nd year Computer Chapter 11: Decision Constructs

2nd year Computer Chapter 11: Decision Constructs

2nd year Chapter 11: Decision Constructs Short and Simple Question & Answer

We are aware that you are searching for 2nd year  Computer Chapter 11 Notes on the internet. The notes are well-written, simple, and organized in an easy-to-understand manner and according to the new syllabus. At the bottom of these notes, you will find a download button to make your life easier. These notes for 2nd year Computer Chapter 11 User Interaction are available to download or view. Many students practice 2024 Computer Notes questions by FAIZ UL ISLAM and get good marks in the exam.

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.

Like Our Facebook Page For Educational Updates faizulislam

For the 2nd year Computer Chapter 11 Introduction to Programming, this set of notes follows the new syllabus, as it is for all Punjab boards. Other boards offer notes that different from this set. Faisalabad Board, Gujranwala Board, Rawalpindi Board, Sargodha Board, DG Khan Board, Lahore Board, Multan Board, Sahiwal Board, AJK Board are some of the boards in Punjab.

the purpose of these notes was to make them as effective as possible. However, mistakes are still possible no matter how hard we try. In any case, if you see them, please let us know by commenting below. We appreciate your ideas and suggestions for improving the study material. Our efforts are meant to benefit all of the community, so we encourage you to share them with your friends, as “Sharing is caring“.

Back to top button