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#include <stdio.h>
2
3int main() {
4 int signal = 0;
5
6 if (signal == 1)
7 printf("Go");
8 else
9 printf("Stop");
10
11 return 0;
12}