Conditional Statements in C: if, if..else, Nested if
What are Conditional Statements?
Conditional statements let a program make decisions and execute different code blocks based on whether a condition is true or false.
The if Statement
if (marks >= 40) {
printf("Pass");
}
The if...else Statement
if (marks >= 40) {
printf("Pass");
} else {
printf("Fail");
}
Nested if
if (marks >= 90) {
printf("Grade A");
} else {
if (marks >= 75) {
printf("Grade B");
}
}
Nested if statements place one if inside another to test multiple layered conditions.
PreviousContinue Statement in C: What is Break & Continue Statement in C with Example
Next Switch Statement in C: Syntax and Examples
Ready to master real-world C Programming development?
Learn C Programming hands-on with mentor-led, live sessions.
.png)