Skip to content
Exercise · Q12

Q.What are conditionals? When they are required in a program?

Puducherry TnboardTextbookSubjective· 2mImportance★★★★★est
83% · 30/36 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Conditionals are decision-making statements — a condition is evaluated to true or false, and the program executes different statements accordingly; they are needed wherever the flow of a program must depend on the data.

What conditionals are. By default, statements run sequentially, one after another. A conditional breaks that straight line: it evaluates a condition — an expression that is either true or false (usually built with relational operators like >, <=, == and logical operators AND/OR/NOT) — and selects which statements execute next. The standard forms are:

  • IF — do something only when the condition is true.
  • IF–ELSE — do one thing when true, another when false.
  • IF–ELSE IF–ELSE (ladder) — choose one among many alternatives.
IF condition THEN
    statements          (run only when condition is true)
ELSE
    other statements    (run only when condition is false)
END IF

When they are required. Whenever a program must make a decision — the same program has to behave differently for different data. Typical situations:

  • Classification: pass/fail from marks, even/odd, grade bands, tariff slabs.
  • Validation: accept an input only if it is in range, else reject it.
  • Choosing a computation: e.g. avoid dividing when the divisor is 0.
  • Menus and options: run the action matching the user's choice.

Example (Python)

num = int(input("Enter a number: "))
if num % 2 == 0:
    print("Even number")
else: …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.