Explain nested if-else with example.
When a series of decision is required, nested if-else is used. Nesting means using one if-else construct within another one. If the condition in the outer if, is true, then only the inner if-else will get executed. Further the statements in the inner if will get execute only if the condition of inner if, evaluates to true. If it is false, the statements in inner else will get executed. If the outer if evaluates to false, then the statements in outer else get executed.
General syntax:
if(condition) {
if(condition) {
statements
} else {
statements
}
} else {
statements
}
statements
Example:
#include<stdio.h>
#include<conio.h>
void main() {
int val;
clrscr();