How a program decides: the decision diamond, its two paths, the modulus operator, and an even or odd flowchart with pseudocode
Most programs have to make decisions: they check a condition and then choose what to do next. In this lesson I explain the if else flowchart: why a program needs decisions, how a decision is drawn in a flowchart, what operands, operators and the modulus operator are, and finally how to check whether a number is even or odd, step by step.
The video is in Hinglish (Hindi and English). This article covers the same ideas in English, so you can read them, revise them and come back to them as the series grows.
Why programs need decisions
Writing a program is not only about doing steps one after another. Very often the next step depends on something: is the user logged in, is the number bigger than 10, is the answer correct? Before the program can continue, it has to check a condition and decide.
So you need to know what a decision is, when you need one, and what its possible outcomes are. That is what this lesson is about.
A real-life decision: when to take an umbrella
We make decisions all the time in real life too. Take a simple one: when should a person take an umbrella when leaving home? It depends on the situation: it may be very hot outside, or it may be the rainy season.
Suppose we decide on the basis of the temperature. Then we first have to check what the temperature is right now. If the temperature is above 40 degrees, then I take the umbrella with me.
Notice what happened: the decision was based on an input (the temperature). I do not pick up the umbrella every day without thinking. I check a parameter, take the decision, and then move on to the next step. A program works in exactly the same way.
The decision symbol in an if else flowchart
In a flowchart, a decision is drawn with a diamond. You write the condition inside the diamond, and the diamond has exactly two exits:

- Yes / True: the condition is fulfilled, so the flow takes this path.
- No / False: the condition is not fulfilled, so the flow takes the other path.
After a decision there are only these two paths: yes or no. There is no path in between. This is how a decision is taken inside a program: check an input against a condition, then follow one of the two paths. In code, this is the if … else statement.
Operands and operators
Before the next example, a quick overview of two words you will hear in every programming lesson. Look at this:
4 + 5 = 9
Here 4 and 5 are the operands: the values we work on. The + is the operator: the operation we perform on the operands. Operands can be two numbers, or two other things a program works with.
The modulus operator (%) gives the remainder
One operator is worth learning early, because many beginner programs become easy with it: the modulus operator, written %. When you apply it to two operands, it gives the remainder of the division. The % sign is just its symbol; it has nothing to do with percentages.

11 % 2 = 1: 2 × 5 = 10, so 1 is left over.8 % 2 = 0: 2 × 4 = 8, nothing is left over.9 % 2 = 1: again, 1 is left over.
We will use modulus to solve many problems in this series. The first one is right below.
Even or odd: thinking it through
Problem: find out whether a number is even or odd.
A number is even when it is divisible by 2, that is, when dividing it by 2 leaves no remainder. If it is not divisible by 2, it is odd. And the remainder is exactly what the modulus operator gives us.
As always, start with input, process and output before drawing anything:
- Input: any number, N.
- Process: check whether N % 2 is 0. This is a check, so it is a decision, and a decision means a diamond.
- Output: “Even” if it is even, “Odd” if it is odd.
The even or odd flowchart and pseudocode
Now the flowchart follows directly:

- Start.
- Read N. N can be any number the user enters when the program runs: 5, 2, 10, anything.
- Decision: is
N % 2 = 0? Two paths come out of it: Yes and No. - Yes: the number is even, so print “Even”.
- No: the number is odd, so print “Odd”.
- End.
The same plan as pseudocode:
READ N
IF N % 2 = 0
PRINT "EVEN"
ELSE
PRINT "ODD"
END IF
Try it with two test cases: 14 % 2 = 0, so 14 is even; 19 % 2 = 1, so 19 is odd.
Two small notes for when you turn this into real code. In most languages the comparison is written == (if (n % 2 == 0)), because a single = assigns a value. And for a negative number the remainder can be negative (in C#, -7 % 2 is -1), which is why we test for 0 rather than for 1.
Video chapters
- 0:00 Why programs need decisions
- 0:46 Real-life decision: the umbrella example
- 2:11 The decision symbol: yes or no
- 3:04 Operators and operands
- 4:19 The modulus operator (%)
- 5:57 Example: even or odd
- 6:48 Even or odd: input, process, decision
- 7:51 The even/odd flowchart
- 8:44 Wrap-up
Watch the short versions
Short on time? These Shorts from this lesson each make one point in a minute or so.
- When to Take an Umbrella? Decisions in Real Life (64 s Short, coming soon, from 0:52 in the full video)
- Decision Symbol in a Flowchart: Only Yes or No (42 s Short, coming soon, from 2:11 in the full video)
- What Does % Do? The Modulus Operator Explained (58 s Short, coming soon, from 4:48 in the full video)
Key takeaways
- Programs make decisions by checking a condition, often based on an input.
- In a flowchart, a decision is a diamond with only two paths: Yes/True and No/False.
- In 4 + 5 = 9, 4 and 5 are operands and + is the operator.
- The modulus operator (%) gives the remainder: 11 % 2 = 1, 8 % 2 = 0.
- A number is even when N % 2 = 0; otherwise it is odd.
Frequently asked questions
What is an if else flowchart?
It is a flowchart that contains a decision: a diamond with a condition written inside it and two paths coming out, Yes/True and No/False. The program follows one path or the other, just like an if … else statement in code.
Which shape is used for a decision in a flowchart?
The diamond. Write the condition inside it, and label its two exits Yes and No (or True and False).
What does the modulus operator (%) do?
It gives the remainder of a division. 11 % 2 is 1 because 2 × 5 = 10 leaves 1, and 8 % 2 is 0 because 2 × 4 = 8 leaves nothing. It is not a percentage; % is only its symbol.
How do you check if a number is even or odd?
Calculate N % 2. If the result is 0, the number is divisible by 2, so it is even; otherwise it is odd. In a flowchart: Start, Read N, a diamond asking N % 2 = 0?, Yes prints Even, No prints Odd, End.
Can a decision have more than two paths?
Not a single decision diamond: it has only two outcomes, yes or no. When you need more choices, you chain several decisions one after another.
Further reading
- Flowchart (Wikipedia): the standard symbols, including the decision diamond and its two paths
- Arithmetic operators: remainder operator % (Microsoft C# reference): how % computes the remainder, including negative numbers
Practice: draw a flowchart that tells whether a number is positive or negative. What condition goes inside the diamond? Write your answer in the comments.
If you want to learn programming from zero, watch the video, subscribe to the channel and follow the series.
