Nested if
A nested if in C is an if statement that is the target of another if statement. Nested if statements mean an if statement inside another if statement. Yes, both C and C++ allow us to nested if statements within if statements, i.e, we can place an if statement inside another if statement.
Syntax:
if (condition1)
{
// Executes when condition1 is true
if (condition2)
{
// Executes when condition2 is true
}
}
Flowchart:
1.To check if char is alphabet, Number or symbol if char is alphabet then check if small case or capital case.
#include<stdio.h>
void main()
{
char ch;
printf("Enter the character=");
scanf("%c",&ch);
if ((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
{
if(ch>='a'&&ch<='z')
{
printf("The Entered character is in small case");
}
else if(ch>='A'&& ch<='Z')
{
printf("The Entered character is in Capital case");
}
}
else if(ch>='0' && ch<='9')
{
printf("The Entered character is Number");
}
else
{
printf("The Enetered Character is Special Symbol");
}
}
Output:
0 Comments