Nested if Statement in C
if statement inside another if statement is called nested if statement.
In other words, placing if statement insie another if statement is called nested if statement. It is helpful in checking a condition inside another condition.
Syntax
if (test expression 1)
{
if (test expression 2)
{
// run code if conditional expression is true
}
}
else
{
// run code if conditional expression is false
}
Program
#include <stdio.h>
int main ()
{
int num = 20;
if(num>=10)
{
if(num == 20)
{
printf("Yes");
}
}
else
{
printf("No");
}
return 0;
}
Output
Yes
Join Our Social Media Connections
0 Comments