Control Statements in C – Forms,
Examples, and Applications
Presented by: Aneesh Fathima
Introduction to Control Statements
• Definition: Control statements allow the flow of
execution to change.
• Purpose: Used for decision-making and repetition in
programs.
• Main Categories:
• - Decision-making statements
• - Looping statements
• - Jump statements
Types of Control Statements
• 1. Decision-making (Selection): if, if-else,
nested if, switch
• 2. Looping (Iteration): for, while, do-while
• 3. Jump (Branching): break, continue, goto,
return
Decision-Making Statements – if, if-else
• Syntax:
if (condition)
{
statement 1
}
else
{
statement 2
}
• Example:
int a = 10;
if (a > 5)
{
printf("a is greater than 5");
}
else
{
printf("a is less than or equal to 5");
}
Nested if and switch Statement
• Nested if: Multiple conditions checked in sequence.
• switch Syntax:
• switch(expression)
{
case value:
statements;
break;
default:
statements;
}
• Example:
int day = 3;
switch(day)
{
case 1: printf(“Monday");
break;
case 2: printf("Tuesday");
break;
case 3: printf("Wednesday");
break;
default: printf("else");
break;
}
Looping – for Loop
• Syntax:
for(initialization; condition; increment)
{
Statement
}
• Example:
for(int i = 0; i < 5; i++)
{
printf(“%d ", i);
}
while and do-while Loops
• while loop: Entry-controlled loop
• do-while loop: Exit-controlled loop
• Example:
• int i = 0;
while(i < 5)
{
printf("%d ", i);
i++;
}
• int j = 0;
do
{
printf("%d ", j);
j++;
} while(j < 5);
Jump Statements – break, continue, goto,
return
• break: Exit loop/switch
• continue: Skip to next iteration
• goto: Jump to labeled block
• Example:
for(int i = 0; i < 5; i++)
{
if(i == 3)
{
break;
}
printf("%d ", i);
}
Applications of Control Statements
• Used in decision trees and menu-driven
programs
• Repetitive tasks like calculations and printing
patterns
• Simulations, games, form validation
• Examples: ATM logic, traffic lights, grading
systems
Summary
• Control statements make programs dynamic
and interactive.
• Improve logic, readability, and efficiency.
• Essential for real-world applications.
Practice Exercises
• Write a program to check if a number is even
or odd using if-else.
• Use for loop to print the first 10 natural
numbers.
• Create a calculator using switch case.
• Design a menu using do-while and break.