In C programming, a statement is an instruction given to the computer to perform a specific task. A C program is essentially a collection of such statements combined logically to carry out computation, decision-making, looping, and more.
Every statement in C is executed sequentially, unless control flow statements change the execution order.
What Is a Statement?
A statement in C is a complete instruction that tells the compiler what action to perform.
Most statements end with a semicolon ( ; ).
Example:
int x = 10;
printf("%d", x);
Types of Statements in C
C supports several types of statements:
- Expression Statements
- Compound Statements
- Null Statements
- Conditional Statements
- Looping (Iterative) Statements
- Jump Statements
Let’s understand each with examples.
1. Expression Statements
These statements contain expressions followed by a semicolon.
Examples:
x = 5;
a = b + c;
printf("Hello");
Any expression that performs an action or calculation is an expression statement.
2. Null Statement
A null statement consists of only a semicolon.
It does nothing but is sometimes used intentionally.
Example:
while (i < 10)
; // do nothing
Used when the loop condition itself performs actions.
3. Compound Statements (Block Statements)
A compound statement is a group of statements enclosed in { }.
Used in if, loops, and functions.
Example:
{
int x = 10;
printf("%d", x);
}
A block is treated as one single statement.
4. Conditional Statements
Used to make decisions based on conditions.
a) if Statement
if (x > 10) {
printf("Greater");
}
b) if-else Statement
if (age >= 18)
printf("Adult");
else
printf("Minor");
c) else-if Ladder
if (marks >= 90)
grade = 'A';
else if (marks >= 75)
grade = 'B';
else
grade = 'C';
d) switch Statement
Used when multiple conditions depend on the same variable.
switch (day) {
case 1: printf("Monday"); break;
case 2: printf("Tuesday"); break;
default: printf("Invalid");
}
5. Looping (Iterative) Statements
Used to execute code repeatedly.
a) for Loop
for (int i = 1; i <= 5; i++) {
printf("%d ", i);
}
b) while Loop
int i = 1;
while (i <= 5) {
printf("%d ", i);
i++;
}
c) do-while Loop
Executes at least once.
int i = 1;
do {
printf("%d ", i);
i++;
} while (i <= 5);
6. Jump Statements
These statements change the normal flow of a program.
a) break
Terminates a loop or switch.
for (int i = 1; i <= 10; i++) {
if (i == 5)
break;
}
b) continue
Skips the current iteration.
for (int i = 1; i <= 5; i++) {
if (i == 3)
continue;
printf("%d ", i);
}
c) goto
Jumps to a labeled statement (use with caution).
goto label;
printf("This won't print");
label:
printf("Jumped using goto");
d) return
Exits from a function and optionally returns a value.
return 0;
7. Function Call Statements
A function call is a valid statement.
printf("Welcome to C");
Example Program Using Different Types of Statements
#include <stdio.h>
int main() {
int num = 10; // Expression statement
if (num > 5) { // Conditional + block
printf("Number is large\n");
}
for (int i = 1; i <= 3; i++) // Loop statement
printf("%d ", i);
printf("\nDone."); // Function call statement
return 0; // Jump statement
}
Conclusion
Statements form the core building blocks of any C program.
By combining different kinds of statements—expressions, conditions, loops, and jumps—you can control program flow and create dynamic and powerful C applications.
🔗 View other articles about C Programming:
https://savanka.com/category/learn/c-programming