Control statements decide which code runs and when. Without them, a C program would only execute top to bottom in a straight line. Decisions (if / switch) pick a branch; jumps (break / continue / goto) steer loops or transfer to a label.
This page teaches how control flow fits a C tutorial: when to choose if vs switch, how else binds, and how jumps work with loops. Each name in the table links to a focused guide with syntax, examples, and FAQs (8 tutorials).
Use braces early.
Always wrap bodies in { }. else binds to the nearest if—braces keep nesting unambiguous and prevent dangling-else bugs.
== vs =
Write if (n == 0) to compare. A single = assigns and is a common beginner bug inside conditions.
switch needs break.
After most case labels, put break; or execution falls into the next case. Fall-through is intentional only when you document it.
Syntax
C Syntax
The main control forms you will use in beginner C programs:
C
/* if — run when condition is true */
if (condition) {
/* body */
}
/* if-else — two branches */
if (condition) {
} else {
}
/* else-if ladder — mutually exclusive outcomes */
if (a) {
} else if (b) {
} else {
}
/* switch — compare one value to constants */
switch (value) {
case 1: /* ... */ break;
default: break;
}
/* jump inside loops */
break; /* leave loop or switch */
continue; /* skip to next iteration */
Compile
C
gcc main.c -std=c11 -o main
Reference
Core C Concepts
How to choose a control form in everyday C tutorial work:
Skip non-positive values; stop when sum exceeds a limit.
C
#include <stdio.h>
int main(void) {
int values[] = {5, -2, 10, 3, 20, 8};
int n = 6;
int sum = 0;
for (int i = 0; i < n; i++) {
if (values[i] <= 0) {
continue;
}
sum += values[i];
if (sum > 25) {
break;
}
}
printf("Stopped at sum: %d\n", sum);
return 0;
}
One line: C control statements choose paths—use if chains for decisions, switch for constants, and break/continue with loops, then open each guide for details.
Frequently Asked Questions
Control statements change program flow based on conditions or jumps. They include if, if-else, else-if, nested if, switch, break, continue, and goto. Together they let programs make decisions and steer loops.
Start with if and if-else for true/false decisions. Add else-if for multiple exclusive outcomes, then nested if for layered checks. Learn switch for menu-style choices, and break/continue once you use loops.
Use switch when comparing one integer or char expression to many constant values (1, 2, 3 or 'A', 'B'). Use else-if for ranges (score >= 80) or unrelated conditions.
break exits the nearest loop or switch entirely. continue skips the rest of the current loop iteration and starts the next one. break is also required after most switch cases to avoid fall-through.
Rarely. Prefer structured if, loops, break, and functions. goto can help in tightly controlled cleanup patterns, but beginners should master if and switch first.
Read the comparison table and examples on this page, then open the if statement tutorial and follow the sidebar order through goto. Pair this track with the C loops tutorials for break and continue practice.