Class 10 Computer Science Unit 3 – Conditional Logic focuses on how programs make decisions based on certain conditions. This unit covers if, if-else, nested if, and switch statements, which allow a program to perform different actions depending on the data provided by the user or computed by the program.
This post includes complete notes, covering decision-making statements, logical operators, and conditional structures, along with MCQs, short-answer questions, and long-answer questions for effective exam preparation.
Important MCQs – Unit 3 Conditional Logic
1. Conditional logic helps in:
a) Decisions ✅
b) Iterations
c) Traversing
d) All
2. In an if statement, what happens if the condition is false?
a) Program crashes
b) Index out of bound error
c) Further code executes ✅
d) Compiler asks to change condition
3. In an if statement, what happens if the condition is false?
a) Program crashes
b) Index out of bound error
c) Further code executes ✅
d) Compiler asks to change condition
4. How many types of control statements are there in C language?
a) Two
b) Three ✅
c) Four
d) Five
Short Questions – Unit 3 Conditional Logic
1. Differentiate between sequential and selection statements.
Answer:
1. Sequential Statements:
-
Represent the default flow of a program.
-
Statements execute in the same order in which they are written.
-
No decision-making is involved.
Example:
printf(“World”);
Output:
World
2. Selection Statements:
-
Allow decision-making in a program.
-
Execute different blocks of code depending on the conditions.
Example:
printf(“Positive”);
} else {
printf(“Non-positive”);
}
Explanation: If x is greater than 0, it prints “Positive”; otherwise, it prints “Non-positive.”
Key Point:
Sequential statements follow a straight-line flow, whereas selection statements change the program flow based on conditions, making the program interactive and flexible.
2. Write the structure of if statement with a brief description.
Answer:
Structure:
// Code to execute if condition is true
}
Brief Description:
-
if⇒ Keyword that starts the decision-making process. -
condition ⇒ Any expression that evaluates to true (non-zero) or false (zero).
-
Code block ⇒ The statements that will run only if the condition is true.
-
{ }⇒ Required when there are multiple statements inside theif. Optional if there is only a single statement.
Example:
if(x > 0) {
printf(“x is positive”);
}
Explanation: The message “x is positive” will be printed only if x is greater than 0.
3. What is an if statement?
Answer:
An if statement is a decision-making statement in C programming. It checks a condition, and if the condition evaluates to true, it executes the associated block of code. If the condition is false, the code inside the if block is skipped, and the program continues with the next statements.
Example:
if(x > 0) {
printf(“x is positive”);
}
Explanation: Since x is greater than 0, the message "x is positive" will be printed. If x were 0 or negative, nothing would be printed.
Key Point:
The if statement is the simplest form of conditional logic, allowing programs to make decisions based on conditions.
Download PDF
Download the complete chapter notes in PDF for easy learning and quick exam revision.
English Medium
Skip to PDF contentThese notes are in English and include all MCQs, short-answer questions, and long-answer questions for Class 10 Computer Science Unit 3 – Conditional Logic.
Urdu Medium
Skip to PDF contentThese notes are translated into Urdu and cover all MCQs, short-answer questions, and long-answer questions for Class 10 Computer Science Unit 3 – Conditional Logic.