3.4.Nested if-else
The if-else statements in if-else statement called nested if-else.
Syntax: if(condition) { if(condition) statement; else statement; } else { if(condition) statement; else statement; }
Example:
#include<iostream.h> #include<conio.h> void main() { int v1,v2,v3,max; cout<<"Enter V1: "; cin>>v1; cout<<"Enter V2: "; cin>>v2; cout<<"Enter V3: "; cin>>v3; if(v1>v2) { if(v1>v3) max=v1; else max=v3; } else { if(v2>v3) max=v2; else max=v3; } cout<<"Maximum is : "<<max; getch(); }