It is perfectly all right if we write an entire if-else construct within either the body of the if statement or the body of an else statement. This is called ‘nesting’of ifs. This is shown in the following program.
#include<stdio.h> int main( ) { int i ; printf ( "Enter either 1 or 2 " ) ; scanf ( "%d", &i ) ; if ( i == 1 ) printf ( "i equals to 1" ) ; else { if ( i == 2 ) printf ( "i equals 2" ) ; else printf ( "i is nor 1 neither 2" ) ; } getchar(); return 0; }