if / else
Try it yourself →Executes code based on a condition.
Syntax
if (condition) { } else { }Description
Condition is inside parentheses. In C, 0 is considered false, non-zero is true (no separate bool needed).
Example
#include <stdio.h>
int main() {
int score = 75;
if (score >= 50) {
printf("Passed\n");
} else {
printf("Failed\n");
}
return 0;
}Expected output
Passed
When to use?
Flow branching.