if–else Statement in C Programming
if–else Statement
Explanation
The if–else statement is used when two possible actions exist. If the condition is true, one block runs; otherwise, the other block runs.
Syntax
if (condition) {
// true block
} else {
// false block
}Flowchart

Real-Life Example
Situation:
If the traffic signal is green, go. Otherwise, stop.
Program
c
1
2#include <stdio.h>
3
4int main() {
5 int signal = 0;
6
7 if (signal == 1)
8 printf("Go");
9 else
10 printf("Stop");
11
12 return 0;
13}