Nesting of conditional statements<\/span><\/p>\n It is always legal to\u00a0nest<\/strong>\u00a0if-else statements, which means you can use one if or else if statement inside another if or else if statement(s).<\/p>\n The syntax for a\u00a0nested if<\/strong>\u00a0statement is as follows:<\/p>\n \u00a0<\/p>\n You can nest\u00a0else if…else<\/strong>\u00a0in the similar way as you have nested\u00a0if<\/em>\u00a0statement.<\/p>\n When the above code is compiled and executed, it produces the following result:<\/p>\n Credits:<\/p>\n <\/a>http:\/ #TC<\/a>1017 #Mastery<\/a>18<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":" Nesting of conditional statements<\/span><\/p>\n It is always legal to nest<\/strong> if-else statements, which means you can use one if or else if statement inside another if or else if statement(s).<\/p>\n The syntax for a nested if<\/strong> statement is as follows:<\/p>\n <\/p>\n You can nest else if…else<\/strong> in the similar way as you have nested if<\/em> statement.<\/p>\n When the above code is compiled and executed, it produces the following result:<\/p>\n Credits:<\/p>\n <\/a>http:\/\/www.tutorialspoint.com\/cplusplus\/cpp_nested_if.htm<\/a><\/p>\nSyntax:<\/h2>\n
#d6d6d6; font-size: 12px; overflow: auto; color: #313131; background-color: #eeeeee;\">if<\/span>(<\/span> boolean_expression <\/span>1<\/span>)<\/span>\n{<\/span>\n \/\/ Executes when the boolean expression 1 is true<\/span>\n if<\/span>(<\/span>boolean_expression <\/span>2<\/span>)<\/span>\n {<\/span>\n \/\/ Executes when the boolean expression 2 is true<\/span>\n }<\/span>\n}<\/span><\/pre>\n
Example:<\/h2>\n
#d6d6d6; font-size: 12px; overflow: auto; color: #313131; cursor: default; background-image: url('http:\/\/www.tutorialspoint.com\/cplusplus\/images\/try-it.jpg') !important; background-attachment: initial !important; background-color: #eeeeee !important; background-size: initial !important; background-origin: initial !important; background-clip: initial !important; background-position: 100% 0%; background-repeat: no-repeat !important;\">#include<\/a><\/span>
#d6d6d6; font-size: 12px; overflow: auto; color: #313131; background-color: #eeeeee;\">Value<\/span> of a <\/span>is<\/span> 100<\/span> and<\/span> b <\/span>is<\/span> 200<\/span>\nExact<\/span> value of a <\/span>is<\/span> :<\/span> 100<\/span>\nExact<\/span> value of b <\/span>is<\/span> :<\/span> 200<\/span><\/pre>\n
Syntax:<\/h2>\n
#d6d6d6; font-size: 12px; overflow: auto; color: #313131; background-color: #eeeeee;\">if<\/span>(<\/span> boolean_expression <\/span>1<\/span>)<\/span>\n{<\/span>\n \/\/ Executes when the boolean expression 1 is true<\/span>\n if<\/span>(<\/span>boolean_expression <\/span>2<\/span>)<\/span>\n {<\/span>\n \/\/ Executes when the boolean expression 2 is true<\/span>\n }<\/span>\n}<\/span><\/pre>\n
Example:<\/h2>\n
#d6d6d6; font-size: 12px; overflow: auto; color: #313131; cursor: default; background-image: url('http:\/\/www.tutorialspoint.com\/cplusplus\/images\/try-it.jpg') !important; background-attachment: initial !important; background-color: #eeeeee !important; background-size: initial !important; background-origin: initial !important; background-clip: initial !important; background-position: 100% 0%; background-repeat: no-repeat !important;\">#include<\/a><\/span> <\/span>\nusing<\/span> namespace<\/span> std<\/span>;<\/span>\n \nint<\/span> main <\/span>()<\/span>\n{<\/span>\n \/\/ local variable declaration:<\/span>\n int<\/span> a <\/span>=<\/span> 100<\/span>;<\/span>\n int<\/span> b <\/span>=<\/span> 200<\/span>;<\/span>\n \n \/\/ check the boolean condition<\/span>\n if<\/span>(<\/span> a <\/span>==<\/span> 100<\/span> )<\/span>\n {<\/span>\n \/\/ if condition is true then check the following<\/span>\n if<\/span>(<\/span> b <\/span>==<\/span> 200<\/span> )<\/span>\n {<\/span>\n \/\/ if condition is true then print the following<\/span>\n cout <\/span> \"Value of a is 100 and b is 200\"<\/span> endl<\/span>;<\/span>\n }<\/span>\n }<\/span>\n cout <\/span> \"Exact value of a is : \"<\/span> a <\/span> endl<\/span>;<\/span>\n cout <\/span> \"Exact value of b is : \"<\/span> b <\/span> endl<\/span>;<\/span>\n \n return<\/span> 0<\/span>;<\/span>\n}<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/pre>\n
#d6d6d6; font-size: 12px; overflow: auto; color: #313131; background-color: #eeeeee;\">Value<\/span> of a <\/span>is<\/span> 100<\/span> and<\/span> b <\/span>is<\/span> 200<\/span>\nExact<\/span> value of a <\/span>is<\/span> :<\/span> 100<\/span>\nExact<\/span> value of b <\/span>is<\/span> :<\/span> 200<\/span><\/pre>\n