Digital Tech Notes (JSS1 - SS3)

Control Structures With Condition In Programming

Learn how computers make decisions using conditional statements like IF and ELSE. A complete JSS 2 guide with Nigerian examples, activities, and asses

INTRODUCTION:

Have you ever used your MTN or Airtel line and received a message like, "You do not have enough airtime to make this call"? Or maybe you have tried to log into your school's online portal and the system said, "Wrong password. Please try again." Ever wondered how the computer knew what to say in each of those situations?

The answer is simple — the computer was following instructions that told it what to do depending on a condition. That is exactly what we are going to explore in this lesson.

In computer programming, we call these instructions conditional statements. They are the tools that give a computer the ability to think and decide. Without them, every program would do the same thing every single time, no matter what. But with conditional statements, a program can check a situation and choose what action to take — just like a human being.

This topic is part of your JSS 2 Computer Studies curriculum under the theme of programming and problem-solving. By the time you finish reading this lesson, you will understand how computers use conditions to make smart decisions, and you will even be able to write a few of your own.


LEARNING OBJECTIVES

By the end of this lesson, students should be able to:

  1. Define the term "conditional statement" in computer programming
  2. Identify the components of an IF and IF...ELSE statement
  3. Explain how decision-making works in a computer program
  4. Write simple conditional statements using correct syntax
  5. Describe real-life situations where conditional statements are applied
  6. Demonstrate the use of conditions in basic programming exercises

WHAT IS A CONDITIONAL STATEMENT?

A conditional statement is an instruction in a program that tells the computer to perform a certain action only when a particular condition is true. If the condition is not true, the computer either does nothing or carries out a different action.

Think about it this way. Imagine you are a school prefect standing at the gate. Your instruction is: "If a student is wearing full uniform, let them in. Otherwise, send them to the VP's office." You are making a decision based on a condition. A computer does the same thing when it uses a conditional statement.

In programming, the most common conditional statement is the IF statement, and it often comes with a partner called the ELSE statement.


THE IF STATEMENT

The IF statement is the most basic form of decision-making in programming. It checks whether something is true, and if it is, the program runs a specific set of instructions.

Here is the general structure:

IF (condition is true) THEN carry out this action

Let us look at a simple real-life example written in pseudocode (a plain language way of writing program logic):

IF student score is greater than or equal to 50 THEN print "You have passed"

In this example, the computer checks whether the student's score meets the pass mark. If the score is 50 or above, it prints "You have passed." Simple and straightforward.

Now imagine the same logic in a Nigerian school setting. Your teacher inputs all scores into a school management software. The software uses an IF statement to check each score and automatically assign a pass or fail remark. That is how useful this is in real life.


THE IF...ELSE STATEMENT

What happens when the condition is NOT true? That is where the ELSE statement comes in. The ELSE part tells the computer what to do when the condition fails.

The structure looks like this:

IF (condition is true) THEN carry out Action A ELSE carry out Action B

Using the same school example:

IF student score is greater than or equal to 50 THEN print "You have passed" ELSE print "You have failed. Please see your teacher."

Now the program handles both possibilities — passing and failing. This is the power of the IF...ELSE statement. No matter what the result is, the program has a plan.

A very common real-life Nigerian example is the ATM machine. When you insert your card and enter your PIN:

IF PIN is correct THEN allow access to your account ELSE display "Incorrect PIN. Try again."

Every time you use a First Bank, Access Bank, or GTBank ATM, this kind of logic is running behind the scenes.


THE IF...ELSE IF...ELSE STATEMENT

Sometimes, there are more than two possible outcomes. In that case, we use a chain of conditions called the IF...ELSE IF...ELSE statement. This allows the program to test multiple conditions one after another until it finds one that is true.

Structure:

IF (first condition is true) THEN do this ELSE IF (second condition is true) THEN do this instead ELSE (if none of the above is true) THEN do this last option

Here is a grading example many Nigerian students will relate to:

IF score is 70 and above THEN grade is A — Distinction

ELSE IF score is 60 to 69 THEN grade is B — Credit

ELSE IF score is 50 to 59 THEN grade is C — Credit

ELSE IF score is 40 to 49 THEN grade is D — Pass

ELSE THEN grade is F — Fail

This is exactly how result-processing software used by schools, WAEC, and NECO works. The system checks your score against a series of conditions and assigns the correct grade automatically.


KEY TERMS YOU SHOULD KNOW

Condition: A statement that can be either true or false. For example, "age is greater than 18" is a condition.

Boolean Value: The result of checking a condition. It is either TRUE or FALSE. This is named after the mathematician George Boole.

Syntax: The correct way to write a programming instruction. Just like grammar rules in English, every programming language has its own syntax.

Pseudocode: A simple, plain-English way of writing program logic without worrying about the exact syntax of a programming language.

Flowchart: A diagram that shows the flow of decisions and actions in a program using shapes and arrows. Diamond shapes are used to represent decisions (conditions).


DECISION-MAKING IN PROGRAMS

Decision-making is at the heart of every useful software application. Without conditions, programs would be rigid and useless in the real world. Here is why decision-making matters in programming:

  • It allows programs to respond differently to different inputs
  • It makes software interactive — the program reacts to what the user does
  • It helps programs detect and handle errors gracefully
  • It allows systems to automate tasks that would otherwise require human judgment

Consider the Cowrywise or PiggyVest savings app. When you try to withdraw your locked savings before the due date, the app does not just let you do it. It checks a condition — "Has the lock period expired?" — and based on the answer, it either allows or blocks the withdrawal. That is decision-making in action.


PRACTICAL APPLICATIONS IN REAL LIFE

Conditional statements are everywhere in the technology we use daily in Nigeria. Here are some practical examples:

1. School Management Systems Schools use software to process results. The system checks each student's score and automatically assigns grades, remarks like "Pass" or "Fail," and even generates report cards — all using IF and ELSE logic.

2. Mobile Banking and Fintech Apps Apps like Kuda, Opay, and Palmpay use conditional logic constantly. When you send money, the app checks: Is your balance enough? Is the recipient's account number valid? Is your transaction PIN correct? Each of these is a condition being evaluated.

3. JAMB and WAEC Online Portals When you register or check results on the JAMB portal, the system uses conditions to verify your details, check if your registration fee has been paid, and display the correct information based on your inputs.

4. Traffic and Security Systems Some modern security cameras and access control systems in Nigerian offices and shopping malls use IF logic — if a face matches a registered ID, access is granted. Otherwise, it is denied.

5. Games and Educational Software In educational games used in primary and secondary schools, conditional logic determines whether a player advances to the next level, loses a life, or gets a reward based on their actions.


ADVANTAGES OF USING CONDITIONAL STATEMENTS

  • They make programs flexible and capable of handling different situations
  • They allow for error detection — programs can warn users when something goes wrong
  • They automate decisions that would otherwise take human time and effort
  • They make software feel intelligent and responsive to the user
  • They are easy to read and understand when written clearly in pseudocode or flowchart form

DISADVANTAGES AND LIMITATIONS

  • Too many nested conditions (conditions inside conditions) can make code difficult to read and maintain
  • A wrong condition written by a programmer can cause the software to make incorrect decisions, which could be dangerous in critical systems
  • If conditions are not written carefully, some situations may be left out, causing the program to crash or behave unexpectedly
  • Beginners sometimes confuse assignment (giving a value) with comparison (checking a value), which leads to errors

ETHICAL AND SAFETY CONSIDERATIONS

As you learn to use conditional logic in programs, it is important to think about how this power can be used responsibly.

Fairness in Automated Decisions: When software uses IF...ELSE logic to make decisions about people — such as who gets a loan, who passes an exam, or who gets hired — the conditions must be fair and unbiased. A poorly written condition can unfairly disadvantage certain groups of people.

Data Privacy: Conditions often check personal information like passwords, ages, and account balances. Programmers must ensure this data is handled securely and not exposed to unauthorised persons.

Accuracy Matters: In critical systems like hospital management software or banking platforms, a wrong condition can cause serious harm. Imagine a system that gives the wrong drug dosage because of a poorly written IF statement. This is why testing and accuracy are essential in programming.

Responsible Use of Technology: As future programmers and technology users, Nigerian students should always think about the impact their code will have on other people.


CLASSROOM AND HOME ACTIVITIES

Activity 1 — Everyday IF Statements Write five IF...ELSE statements based on decisions you make in your daily life. For example: "IF it is raining, THEN I will carry an umbrella, ELSE I will leave it at home." Share your statements with a partner and discuss.

Activity 2 — Trace the Flowchart Draw a flowchart for the following situation: A student wants to buy data on their phone. IF the account balance is greater than ₦200, buy 1GB data. ELSE IF the balance is between ₦100 and ₦200, buy 500MB. ELSE display "Insufficient balance." Use the correct flowchart symbols (oval for start/end, diamond for decisions, rectangle for actions).

Activity 3 — Scratch Programming Exercise Open Scratch (scratch.mit.edu) and create a simple quiz program. Use the "if...then...else" block to check whether a user's answer is correct. If correct, make the sprite say "Well done!" If wrong, make it say "Try again!"

Activity 4 — Spot the Condition Look at two apps on a phone or computer (e.g., a calculator or a simple game). Write down at least three decisions you think the app is making using conditional logic. Discuss your findings with the class.


ASSESSMENT QUESTIONS

Section A — Objective Questions

  1. Which of the following best describes a conditional statement? a) A statement that repeats instructions b) A statement that makes decisions based on a condition c) A statement that stores data in memory d) A statement that defines a variable

  2. In an IF...ELSE statement, the ELSE part runs when: a) The condition is true b) The program starts c) The condition is false d) The loop ends

  3. What shape is used to represent a decision in a flowchart? a) Rectangle b) Oval c) Diamond d) Circle

  4. Which of the following is a Boolean value? a) 100 b) "Hello" c) TRUE d) 3.14

  5. A Nigerian bank ATM uses conditional logic to check your PIN. This is an example of: a) Loop statement b) Decision-making in programs c) Variable declaration d) Data storage

Section B — Theory Questions

  1. Explain the difference between an IF statement and an IF...ELSE statement. Use a Nigerian example to illustrate your answer.

  2. A school software is designed to grade students based on their scores. Write a pseudocode using IF...ELSE IF...ELSE to assign grades from A to F for scores ranging from 0 to 100.

  3. Why is it important to write accurate and fair conditions in programming? Give two real-life examples where a wrongly written condition could cause problems.


SUMMARY

In this lesson, we learned that conditional statements are instructions that allow a program to make decisions. The IF statement checks a condition and runs a block of code if that condition is true. The IF...ELSE statement adds a second option for when the condition is false. The IF...ELSE IF...ELSE structure handles multiple conditions in sequence.

We also explored how these concepts are used in everyday Nigerian technology — from ATM machines and fintech apps to school management systems and JAMB portals. We learned important terms like condition, Boolean value, pseudocode, and flowchart, and we discussed the ethical responsibility that comes with writing code that makes decisions affecting people.


CONCLUSION

Conditional statements are truly the building blocks of intelligent software. Without them, computers would be nothing more than very expensive calculators. With them, software can respond, adapt, and make decisions — just like a human being.

As a JSS 2 student in Nigeria, understanding how IF and ELSE work is your first real step into the world of programming and software development. The logic you are learning today is the same logic used by the developers who built the apps you use on your phone, the platforms WAEC uses to process results, and the systems banks use to keep your money safe.

Keep practising, stay curious, and remember — every smart program starts with a simple condition.


FREQUENTLY ASKED QUESTIONS (FAQ)

Q1: What is a conditional statement in computer programming? A conditional statement is a programming instruction that checks whether a condition is true or false and then decides what action to take based on that result. The most common examples are the IF statement and the IF...ELSE statement.

Q2: What is the difference between IF and IF...ELSE? An IF statement only tells the computer what to do when a condition is true. An IF...ELSE statement goes further by also telling the computer what to do when the condition is false, making the program more complete and flexible.

Q3: Can a program have more than two conditions? Yes. When you need to check more than two possible outcomes, you use the IF...ELSE IF...ELSE structure. This allows you to test several conditions one after the other until a true one is found.

Q4: How are conditional statements used in Nigerian apps? Many Nigerian apps use conditional logic. For example, when you transfer money on Opay, the app checks if your balance is sufficient (a condition). If yes, the transfer goes through. If not, you get an error message. This is an IF...ELSE decision running in the background.

Q5: What is a Boolean value and why is it important in conditions? A Boolean value is the result of evaluating a condition — it is either TRUE or FALSE. It is important because every condition in a program must produce one of these two results so the computer knows which path to follow.

Q6: Do I need to know how to code to understand conditional statements? Not necessarily. You can understand the concept through pseudocode and flowcharts, which do not require a specific programming language. However, practising with tools like Scratch is a great and easy way to see conditional logic working in real programs.

I am Echofu George Adah, the Pioneer of Digital Tech Note and the Founder and Chief Executive Officer of GeoWeb Technologies Limited, an information technology company committed to providing cutting-edge ICT solutions.