C Programming/Conditional statements

C if Statement

Updated on January 8, 2026
1 min read

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
}

Flowcharthttps://media.geeksforgeeks.org/wp-content/uploads/20230310131453/flowchart-of-if-in-c.png

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}
C if Statement | C Programming | Learn Syntax