Answer :
Answer:
The answer to this question can be given as:
// code to if-else ladder statement can be given as:
if(isBalloon==true && isRed!=true) //if block
{
cout<<"Balloon"; //message
}
else if ((isBalloon && isRed)==true) //else if block
{
cout<<"Red balloon"; //message
}
else //else block
{
cout<<"Not a balloon"; //message
}
Explanation:
In the above code, we use the if-else ladder statement. In this statement, we use two variables and AND logical operator. AND operator executes when both condition is true. The following if-else ladder statement can be described as:
- In the if block, we check the two conditions that the variable isBalloon value is "true" and the variable isRed value is "false". Then it prints "Balloon" on console.
- In the else-if block, we check if both variables (isBalloon and isRed) value is "true". Then it prints "Red balloon" on console.
- finally, if both above condition is false then It print "Not a balloon" on console.