Advertisement



< Prev
Next >



C++ Nested If Statement





In C++, the nested-if is another decision making statement in which an if statement is nested inside an outer if statement, hence it is named nested if.

The statement connected to the nested if statement is only executed when -:






/* C++ nested if statement*/

#include

using namespace std;
int main()
{
if('c'>'a')
{
	// A nested if  statement
	if('c'>'b')  
	cout<<"c is greater than b and c is greater than a";
}

else 
	cout<<"b is not less than a";
	
return 0;
}


Output


c is greater than b and c is greater than a

In the latter program, we have compared values in char variables using nested if statement, internally their ASCII values have been compared to find out which character has a greater ASCII value.



Please share this article -





< Prev
Next >
< Else-If Statement
Nested If-Else Statement>



Advertisement

Please Subscribe

Please subscribe to our social media channels for daily updates.


Decodejava Facebook Page  DecodeJava Twitter Page Decodejava Google+ Page




Advertisement

Notifications



Please check our latest addition

PYTHON


Advertisement