Understanding Decision-Making with If–Else Statements in C Programming
In C Programming decision statements is very vital. Because it helps us to frame conditions and based on those conditions we can perform certain tasks/actions otherwise not. We enforce this using if-Else statements.
PROGRAMMINGC PROGRAMMINGCONDITIONAL STATEMENTS IN CIF ELSE IF LADDER PROGRAMS
12/13/20252 min read


Introduction to Decision-Making in C Programming
In C Programming decision statements is very vital. Because it helps us to frame conditions and based on those conditions we can perform certain tasks/actions otherwise not.
In real life we act like that only right? Lets say - "If it rains today I will buy an umbrella" - this is a typical conditional statement where if a condition is met , I will perform the purchase of umbrella.
Similarly in programming we need to enforce this kinds of logic. For that we have if-else and if-else-if statements. Lets study them one by one.
The If–Else Statement
We use if- else statement when we have only two choices.If the condition in the if is true then the block below it will run.
If it is false then the block under the else clause will run.
Understanding If–Else–If Ladder
In many cases we might need to check multiple conditions. In that scenario we need to check conditions in a series - that looks like a ladder like sequence.
One if followed by else - in which we combine another if and then its else and so on.
That is the if-else-if ladder. The program checks each condition one by one unless one condition is true.
Other resources: Read about Important Math Functions and Programs
Important Programs Using If–Else–If Ladder
Q1. Find the Highest and Lowest Number Among Three Numbers
Write a program to input three numbers and find which one is highest and which one is lowest.
Q2. Check Whether a Triangle is Right-Angled or Not
Input three sides of a triangle and check if it is a right-angled triangle or not.
Q4. Menu-Driven Program for Cuboid (Area or Volume)
Input a choice (1 or 2) and the length, breadth, and height of a cuboid.
If choice is 1, find area.
If choice is 2, find volume.
Otherwise, show “wrong choice”.
If user enters 1 → area formula runs.
If user enters 2 → volume formula runs.
Otherwise, “Wrong Choice” prints.
Q5. Check Whether a Triangle is Scalene, Isosceles, or Equilateral
Input three sides of a triangle and find if it is Scalene, Isosceles, or Equilateral.
All sides equal → Equilateral.
Any two sides equal → Isosceles.
All sides different → Scalene.
Q6. Employee Salary Calculation
Input name and basic salary of an employee.
Calculate DA, HRA, Income Tax, and Net Salary based on conditions.
We give DA and HRA based on salary range.
If total salary is more than ₹50,000, 10% tax applies.
Final salary = basic + hra + da − tax.
Q7. Find the Second Highest Number Among Three
Input three numbers and find which is the second highest number.
We check which number is in between the other two using conditions.
That number is the second largest.
Conclusion
In this topic, you learnt how to use if–else and if–else–if ladder for decision making in C.
These programs are very important for practical lab exams and interview logic tests.
Try changing values and conditions to understand how the program flow changes.
Keep practicing — logic building is the real key to mastering C programming!
For enrolling to our online course click on : Register