Reading Time: 7 minutes
Published: 25 October 2025
Decision-making statements, such as if, if-else, and switch, are the most fundamental components for controlling the flow of a program based on predefined conditions. They allow a program to check a condition and then follow different execution paths depending on whether the condition is true or false. These statements have been introduced to give programs the ability to change and be more adaptable, thus allowing the implementation of complex decision-based logic. They are the ones who make programs capable of handling different situations and responding accordingly. Through decision-making statements, developers can build software that reacts differently to other inputs, making it more intelligent and interactive.
This article will explore the types of decision-making statements with their syntax and examples.
A decision-making statement in C controls the program's flow based on certain conditions. These statements are called conditional statements because they evaluate conditions using Boolean expressions (true or false). Different blocks of code are executed depending on whether the condition is evaluated as true or false.
One of the most basic features of any programming language is conditional statements, which make decisions depending on specific conditions, just like human decisions. These statements allow the program to select the next block of code to run. For instance, if an "if" statement checks a condition and the condition is true, a specific action is performed; otherwise, the "else" block executes a different action. Besides that, it is possible to use "else-if" statements to handle multiple conditions and enable more complex decision-making. Such control over the program flow is indispensable to its functioning, as it allows it to respond correctly to different inputs or situations.
The decision making statements are required for the following reasons:
Branching gives the program the ability to choose among different execution paths based on specified conditions. In most programming languages, these statements perform a single or multiple function calls, check whether a condition (or multiple conditions) is true or false, and execute the corresponding code blocks, e.g., if, else, and elif.
Control flow is the mechanism that moves the program from one part to another; thus, it is responsible for the order of program execution. It also determines how statements, functions, and loops are processed. With the help of conditionals (like if statements) and control structures (like loops and switches), you can decide the program's behaviour and which statements will be executed next.
Using conditional statements, your program can handle different cases efficiently. For instance, checking for multiple conditions using if-elif-else blocks allows you to distinguish between situations such as error handling, edge cases, or unique user inputs, and then perform the appropriate action for each case.
Event-driven programming is a way to program where events (such as user input, button clicks, or changes in data) cause the following actions to be performed. The use of conditionals is essential for determining the program's reaction to each event, ensuring the correct decision-making is used depending on the type of event. Such a system can exhibit behaviour that is dynamically responsive to changes in the user interface or the internal state of the system.
Quick Note: They add flexibility by breaking complex problems into manageable steps.
Here are the types of decision-making statements in C:
Quick Note: These types handle simple to complex decisions efficiently.
The if statement may be implemented in different forms depending on the complexity of the conditions to be tested. The different forms are:
The if statement is one of the simplest decision-making in C. It checks a condition and executes a block of code if the condition is true.
if (condition) {
// Code executes if the condition is true
}
#include <stdio.h>
int main() {
int x = 10;
if (x > 5) {
printf("x is greater than 5");
}
return 0;
}
a is greater than 5
The program declares an integer x with a value of 10. It then checks if a is greater than 5 using an if statement. Since the condition is true, it prints "x is greater than 5" to the screen.
The if-else statement provides an alternative block of code that runs if the condition is false.
if (condition) {
// code executes if condition is true
} else {
// code executes if condition is false
}
#include <stdio.h>
int main() {
int x = 2;
if (x > 5) {
printf("x is greater than 5\n");
} else {
printf("x is less than or equal to 5\n");
}
return 0;
}
x is less than or equal to 5
In C programming, a nested if statement refers to placing one 'if' statement inside another 'if' or 'else' block. This approach allows you to handle more complex conditional logic and make decisions based on multiple, layered conditions. Nested if statements are a powerful feature of conditional statements and are commonly used in control structures when you need to check for several related conditions.
if (condition1) {
if (condition2) {
// code executes if both conditions are true
}
}
#include <stdio.h>
int main() {
int x = 10, y = 5;
if (x > 5) {
if (y < 10) {
printf("Both conditions are true\n");
}
}
return 0;
}
Both conditions are true
Note: You can use one if or else-if statement inside another if or else-if statement(s).
#include <stdio.h>
int main() {
int a = 10, b = 5, c = 7;
if (a > b) { // Check if a is greater than b
if (c > b) { // Nested condition: if c is greater than b
printf("a > b and c > b\n"); // Executes if both conditions are true
} else { // If c is not greater than b
printf("a > b but c <= b\n"); // Executes when a > b and c <= b
}
} else if (a == b) { // Executes if a is equal to b
printf("a is equal to b\n");
} else { // Executes if a < b
printf("a < b\n");
}
return 0;
}
a > b and c > b
An if-else-if ladder is used to evaluate multiple conditions sequentially. It allows you to check several conditions one by one and execute different blocks of code depending on which condition is true.
if (condition1) {
// code executes if condition1 is true
} else if (condition2) {
// code executes if condition2 is true
} else {
// code executes if no conditions are true
}
#include <stdio.h>
int main() {
int x = 15;
if (x > 20) {
printf("x is greater than 20\n");
} else if (x > 10) {
printf("x is greater than 10 but less than or equal to 20\n");
} else {
printf("x is less than or equal to 10\n");
}
return 0;
}
x is greater than 10 but less than or equal to 20
In the above program, the first condition is false (x > 20), but the second condition is true (x > 10), so the corresponding message is printed.
Note: The nested if is used for hierarchical conditions (if condition inside another if) and if-else if ladder is for checking multiple conditions.
Key Takeaways So Far:
The switch statement allows multi-way branching. It checks a variable against multiple possible values and executes the corresponding code block.
switch (variable) {
case value1:
// code executes if variable == value1
break;
case value2:
// code executes if variable == value2
break;
default:
// code executes if variable doesn't match any case
}
#include <stdio.h>
int main() {
int x = 2;
switch (x) {
case 1:
printf("x is 1\n");
break;
case 2:
printf("x is 2\n");
break;
default:
printf("x is something else\n");
break;
}
return 0;
}
x is 2
The conditional (ternary) operator is a shorthand for if-else statements, with three operands: condition, true-case expression, and false-case expression.
condition ? expression1 : expression2;
#include <stdio.h>
int main() {
int x = 10;
(x > 5) ? printf("x is greater than 5\n") : printf("x is less than or equal to 5\n");
return 0;
}
x is greater than 5
Jump statements control the flow of execution in loops and functions. The jump statements are further divided into four types:
Terminates the loop or switch statement.
break;
#include <stdio.h>
int main() {
for (int i = 0; i < 5; i++) {
if (i == 3) break;
printf("%d ", i);
}
return 0;
}
0 1 2
The break exits the loop when i equals 3, so only 0, 1, and 2 are printed.
This code skips the current loop iteration and moves on to the next iteration.
continue;
#include <stdio.h>
int main() {
for (int i = 0; i < 5; i++) {
if (i == 3) continue;
printf("%d ", i);
}
return 0;
}
0 1 2 4
In the above program, the continue skips the iteration when i equals 3, so 3 is not printed.
Transfers control to a labelled statement. (Not recommended due to readability concerns.)
goto label;
#include <stdio.h>
int main() {
int i = 0;
start:
if (i < 3) {
printf("%d ", i);
i++;
goto start;
}
return 0;
}
0 1 2
The goto sends control back to the start label, creating a loop that prints 0, 1, and 2.
Exits from a function, optionally returning a value.
return value;
#include <stdio.h>
int main() {
printf("Before return\n");
return 0;
printf("After return\n"); // This line will not execute
}
Before return
The return statement exits the primary function, so the second print statement is never executed.
Key Takeaways So Far:
Candidates can prepare these questions on decision-making statements in C:
#include <stdio.h>
int main() {
int num;
printf("Enter a number: ");
scanf("%d", &num);
if (num % 2 == 0) {
printf("The number is even.\n");
} else {
printf("The number is odd.\n");
}
return 0;
}
Enter a number: 7
The number is odd.
#include <stdio.h>
int main() {
int a, b, c;
printf("Enter three numbers: ");
scanf("%d %d %d", &a, &b, &c);
if (a >= b && a >= c) {
printf("The largest number is %d\n", a);
} else if (b >= a && b >= c) {
printf("The largest number is %d\n", b);
} else {
printf("The largest number is %d\n", c);
}
return 0;
}
Enter three numbers: 5 8 3
The largest number is 8
#include <stdio.h>
int main() {
int year;
printf("Enter a year: ");
scanf("%d", &year);
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
printf("%d is a leap year.\n", year);
} else {
printf("%d is not a leap year.\n", year);
}
return 0;
}
Enter a year: 2024
2024 is a leap year.
#include <stdio.h>
int main() {
int marks;
printf("Enter marks: ");
scanf("%d", &marks);
if (marks >= 90) {
printf("Grade A\n");
} else if (marks >= 70) {
printf("Grade B\n");
} else if (marks >= 50) {
printf("Grade C\n");
} else {
printf("Grade F\n");
}
return 0;
}
Enter marks: 85
Grade B
Key Takeaways So Far:
Here are the advantages and disadvantages of decision-making statements in C programming:
To sum up, decision-making statements in C are essential tools to manage how the program flows. They facilitate the execution of different operations depending on the given conditions, thus increasing a program's adaptability and its ability to respond to changing situations. Command of these statements is the main factor in producing code that is not only effective but also makes sense and is easy to maintain in the C language.
Decision-making statements in C enable efficient logic in embedded systems, games, and AI prototypes. They ensure programs handle real-time inputs, but overuse can lead to bugs—master for scalable, maintainable code in tech careers.
The three main types of control structures in C are:
The four types of control statements in C are:
A) if (condition) { statement; }
B) if condition { statement; }
C) if (condition) statement;
D) if condition then statement;
Answer: A) if (condition) { statement; }
A) if
B) else
C) switch
D) continue
Answer: B) else
A) exit;
B) continue;
C) break;
D) stop;
Answer: C) break;
A) if
B) else if
C) case
D) while
Answer: D) while (It's a loop, not a decision-making statement)
A) default
B) case
C) exit
D) break
Answer: A) default
Complete Guide on String Functions in C - Learn essential string functions in C with syntax, examples, memory rules, and safe practices. (5 min read)
Mastering Insertion Sort in C: Code, Logic, and Applications - Understand insertion sort in C with easy-to-follow logic, code examples, and practical tips. (6 min read)
Quick Sort Algorithm Explained: Steps, Code Examples and Use Cases - Learn the Quick Sort Algorithm with clear steps, partition logic, Python & C++ code examples. (6 min read)
Switch Statement in C: Syntax, Flowchart & Sample Programs - Learn how to use the switch statement in C programming with simple syntax and real-life examples. (6 min read)
The Ultimate Guide to Binary Search Algorithm in C - Learn the Binary Search Algorithm with steps, examples, and efficiency insights. (8 min read)
Merge Sort in C: A Step-by-Step Guide with Code Examples - Learn how Merge Sort works in C with easy-to-follow examples and step-by-step logic. (8 min read)
NxtWave is a learning platform offering industry-recognized certifications and courses in software development, data analysis, and emerging technologies. The platform provides structured learning paths for college students and professionals looking to build careers in IT.
Contact Information:
Course Offerings: