Nested "if else statements" play an essential role in C programming; It simply means the use of conditional statements inside another conditional statement.
The basic format of the Nested if-else statement is:
Syntax:
if(test_expression one) { if(test_expression two) { //Statement block Executes when the boolean test expression two is true. } } else { //else statement block }
Example of a C Program to Demonstrate Nested if-else Statement
Example:
#include<stdio.h> void main() { int x=20,y=30; if(x==20) { if(y==30) { printf("value of x is 20, and value of y is 30."); } } }
Execution of the above code produces the following result.
Output:
value of x is 20, and value of y is 30.
Nested if-else Statements in C - Video Tutorial
Please watch this video tutorial to understand "C Nested if-else Statements" in more depth.
Keep W3schools Growing with Your Support!
❤️ Support W3schools