Nested if Statement in C++

An if ststement within another if statement is called Nested if statement. One is called outter if and other is called inner if statement. Control transfer to inner if statement only if condition of outter if statement retrun true.

Syntax

if ( condition )

   if ( condition )

        statement;

Example

#include <iostream>
using namespace std;

int main(int argc, char** argv) {
	
	int a = 5;
	
	if(a > 1)
	  if( a< 10)
	     cout<<"Given Value is Greater Than 1 and Less Than 10";
	
	return 0;
}

If there are more than one statements in Nested structure then we shall use curly parentheses to make block of statements.

Comments
Login to TRACK of Comments.