Decision Making Statements in C: Type & its Examples

Reading Time: 7 minutes

Published: 25 October 2025


Key Takeaways from the Blog


Introduction

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.


What are Decision Making Statements in C?

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.


Need for Decision-Making Statements

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:

1. Branching

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.

2. Control Flow

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.

3. Handling Different Cases

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.

4. Event-Driven Programming

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.


Types of Decision-making Statements in C

Here are the types of decision-making statements in C:

  1. if statement
  2. switch statement
  3. conditional operator statement (? : operator)
  4. Jump Statements:
    • Break
    • Continue
    • Return
    • goto statement

Quick Note: These types handle simple to complex decisions efficiently.


Decision-making with if statement

The if statement may be implemented in different forms depending on the complexity of the conditions to be tested. The different forms are:

1. if Statement

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.

Syntax

if (condition) {
    // Code executes if the condition is true
}

Example

#include <stdio.h>
int main() {
    int x = 10;
    if (x > 5) {
        printf("x is greater than 5");
    }
    return 0;
}

Output

a is greater than 5

Explanation

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.


2. if-else Statement

The if-else statement provides an alternative block of code that runs if the condition is false.

Syntax

if (condition) {
    // code executes if condition is true
} else {
    // code executes if condition is false
}

Example

#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;
}

Output

x is less than or equal to 5

Explanation


3. Nested if Statement

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.

Syntax

if (condition1) {
    if (condition2) {
        // code executes if both conditions are true
    }
}

Example

#include <stdio.h>
int main() {
    int x = 10, y = 5;
    if (x > 5) {
        if (y < 10) {
            printf("Both conditions are true\n");
        }
    }
    return 0;
}

Output

Both conditions are true

Explanation

Note: You can use one if or else-if statement inside another if or else-if statement(s).

Example with Nested if-else

#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;
}

Output

a > b and c > b

Explanation


4. if-else-if Ladder

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.

Syntax

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
}

Example

#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;
}

Output

x is greater than 10 but less than or equal to 20

Explanation

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:


5. switch Statement

The switch statement allows multi-way branching. It checks a variable against multiple possible values and executes the corresponding code block.

Syntax

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
}

Example

#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;
}

Output

x is 2

Explanation


6. Conditional Operator (? :)

The conditional (ternary) operator is a shorthand for if-else statements, with three operands: condition, true-case expression, and false-case expression.

Syntax

condition ? expression1 : expression2;

Example

#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;
}

Output

x is greater than 5

Explanation


7. Jump Statements

Jump statements control the flow of execution in loops and functions. The jump statements are further divided into four types:

1. Break

Terminates the loop or switch statement.

Syntax
break;
Example
#include <stdio.h>
int main() {
    for (int i = 0; i < 5; i++) {
        if (i == 3) break;
        printf("%d ", i);
    }
    return 0;
}
Output
0 1 2
Explanation

The break exits the loop when i equals 3, so only 0, 1, and 2 are printed.


2. Continue

This code skips the current loop iteration and moves on to the next iteration.

Syntax
continue;
Example
#include <stdio.h>
int main() {
    for (int i = 0; i < 5; i++) {
        if (i == 3) continue;
        printf("%d ", i);
    }
    return 0;
}
Output
0 1 2 4
Explanation

In the above program, the continue skips the iteration when i equals 3, so 3 is not printed.


3. Goto

Transfers control to a labelled statement. (Not recommended due to readability concerns.)

Syntax
goto label;
Example
#include <stdio.h>
int main() {
    int i = 0;
    start:
    if (i < 3) {
        printf("%d ", i);
        i++;
        goto start;
    }
    return 0;
}
Output
0 1 2
Explanation

The goto sends control back to the start label, creating a loop that prints 0, 1, and 2.


4. Return

Exits from a function, optionally returning a value.

Syntax
return value;
Example
#include <stdio.h>
int main() {
    printf("Before return\n");
    return 0;
    printf("After return\n");  // This line will not execute
}
Output
Before return
Explanation

The return statement exits the primary function, so the second print statement is never executed.

Key Takeaways So Far:


Popular Questions Asked on Decision-Making Statements in C

Candidates can prepare these questions on decision-making statements in C:

Problem 1: Write a C program to check whether a given number is even or odd.

Code

#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;
}

Output

Enter a number: 7
The number is odd.

Explanation


Problem 2: Write a C program to find the largest of three numbers.

Code

#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;
}

Output

Enter three numbers: 5 8 3
The largest number is 8

Explanation


Problem 3: Write a program to check whether a given year is a leap year.

Code

#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;
}

Output

Enter a year: 2024
2024 is a leap year.

Explanation


Problem 4: Write a program to input a student's marks and display the grade based on the marks.

Code

#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;
}

Output

Enter marks: 85
Grade B

Explanation

Key Takeaways So Far:


Advantages and Disadvantages of Decision Making Statements in C

Here are the advantages and disadvantages of decision-making statements in C programming:

Advantages

Disadvantages


Conclusion

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.

Why It Matters?

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.

Practical Advice for Learners


Frequently Asked Questions

1. What are the 3 types of control structures?

The three main types of control structures in C are:

2. What are the four types of control statements?

The four types of control statements in C are:


Practice Questions on Decision Making Statements in C

Question 1: Which is the correct syntax for an if statement in C?

A) if (condition) { statement; }

B) if condition { statement; }

C) if (condition) statement;

D) if condition then statement;

Answer: A) if (condition) { statement; }


Question 2: Which of the following C statements will execute only when the condition is false?

A) if

B) else

C) switch

D) continue

Answer: B) else


Question 3: Which of the following statements is used to exit a switch case in C?

A) exit;

B) continue;

C) break;

D) stop;

Answer: C) break;


Question 4: Which of the following is NOT a valid decision-making statement in C?

A) if

B) else if

C) case

D) while

Answer: D) while (It's a loop, not a decision-making statement)


Question 5: Which of the following C constructs will allow a block of code to be executed if no condition is true in a switch statement?

A) default

B) case

C) exit

D) break

Answer: A) default


Related Articles


About NxtWave

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: