if Statement in C Programming
if Statement
Explanation
The if statement is used when you want to execute a block of code only if a condition is true.
If the condition is false, the code inside if is skipped.
Syntax
if (condition) {
// code executes if condition is true
}Flowchart
Real-Life Example
Situation:
If it is raining, take an umbrella.
Program
c
1
2#include <stdio.h>
3int main() {
4 int raining = 1;
5 if (raining == 1) {
6 printf("Take an umbrella");
7 }
8 return 0;
9}