JavaScript
let mark=82;
if(mark>=35){
if(mark>=75) console.log("Pass with Distinction");
else console.log("Pass");
}else console.log("Fail");Condition inside condition with real-life example
Nested if means an if condition written inside another if condition. The inner condition is checked only if the outer condition is true.
First check pass. If pass, then check distinction.
Inner if does not run when outer if is false.
let mark=82;
if(mark>=35){
if(mark>=75) console.log("Pass with Distinction");
else console.log("Pass");
}else console.log("Fail");int mark=82;
if(mark>=35){
if(mark>=75) cout<<"Pass with Distinction";
else cout<<"Pass";
}else cout<<"Fail";mark=82
if mark>=35:
if mark>=75:
print("Pass with Distinction")
else:
print("Pass")
else:
print("Fail")<?php
$mark=82;
if($mark>=35){
if($mark>=75) echo "Pass with Distinction";
else echo "Pass";
}else echo "Fail";
?>Outer if checks first. Inner if checks next.