c / beginner
Snippet
If-Else Control Flow
Conditional statements allow the program to make decisions and execute different blocks of code based on a boolean expression.
snippet.c
1
2
3
4
5
6
7
int score = 85;if (score >= 50) {printf("Pass\n");} else {printf("Fail\n");}
Breakdown
1
if (score >= 50)
Checks if the score is greater than or equal to 50.
2
else { ... }
The block that runs if the initial condition is false.