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#include <stdio.h>
2int main() {
3  int raining = 1;
4  if (raining == 1) {
5    printf("Take an umbrella");
6  }
7  return 0;
8}
C if Statement | C Programming | Learn Syntax