TaleemBay
Study
UniversitiesScholarshipsFeesDates
TaleemBay

Empowering students with Next-Gen tools for a brighter future. Your one-stop destination for education in Pakistan.

Quick Links

  • Universities
  • Study Center
  • Past Papers
  • Date Sheets
  • Results

Support

  • About Us
  • Contact
  • Privacy Policy
  • Terms of Service
  • Advertise

Contact Us

  • Arfa Software Technology Park,
    Ferozepur Road, Lahore
  • +92 300 1234567
  • hello@taleembay.com

© 2026 TaleemBay. All rights reserved.

Designed with ❤️ for Pakistan

Home
Unis
Study

Study Center

Overview
9th Class10th Class11th Class12th Class

Resources

Past PapersDate Sheets

Need Notes?

AI-powered search for instant answers.

Chapter 11
computer-science • intermediate 12th

Chapter 11: Decision Constructs

Comprehensive notes for Chapter 11 Decision Constructs. Covers Control Structures, if, if-else, switch statements, and Conditional Operator.

Control Structures

Definition: Statements used to control the flow of execution in a program.

  • Sequence: Statements executed in the same order as they appear. Default mode.
  • Selection: Selects a statement or set of statements to execute based on a condition (e.g., if, switch).
  • Repetition: Executes a statement or set of statements repeatedly (e.g., while, for loops).

if Statement

Definition: Simpson selection structure. Executes a block of code only if a specified condition is true.

Syntax: if (condition) { statement(s); }

If the condition is false, the code block is skipped.

if-else Statement

Definition: Two-way selection structure. Executes one block if condition is true, and another block if condition is false.

Syntax: if (condition) { statement1; } else { statement2; }

Nested if Statement

Definition: An if statement inside another if statement.

Working: Inner if is executed only if the outer if condition is true. Used for complex multiple-condition checks.

Multiple if-else-if Statement

Definition: Used to choose one block from many options.

Syntax: if (cond1) { ... } else if (cond2) { ... } else { ... }

Conditions are checked in sequence. First true condition executes its block. If none are true, the final else block executes.

Switch Statement

Definition: Multi-way selection structure. Alternative to nested if-else-if when checking a single variable against many constant values.

Syntax: switch(expression) { case val1: ... break; case val2: ... break; default: ... }

  • case: Labels must be constant integers or characters.
  • break: Exits the switch structure. If omitted, execution falls through to next case.
  • default: Executed if no case matches (optional).

Conditional Operator

Definition: Ternary operator (takes 3 operands). Shorthand for simple if-else.

Syntax: (condition) ? true_statement : false_statement;

Example: max = (a > b) ? a : b; assigns the larger of a and b to max.