Ask Question
30 August, 15:07

How can the compound conditional expression ((average > 79 && average < = 89)) be written to eliminate the logical operator - without changing the logic?

+5
Answers (1)
  1. 30 August, 18:42
    0
    Remove the && and create a nested if statement.

    Explanation:

    The statement ((average > 79 && average < = 89)) states a condition that the value of average is supposed to be greater than 79 and less than equals to 89. Since AND (&&) operator is being used between both the expressions so both should be true to make the condition evaluate to true. This means that value of average variable is greater than 79 AND less than or equal to 89.

    Now the logical operator && can be eliminated by using nested-if statement which refers to the if statement inside another if statement. So the above statement can be written as:

    if (average>79)

    {

    if (average<=89)

    }

    It will check firstly the average value for being greater than 79 (if average value is greater than 79?) AND then check average value to see if that less than or equal to 89.

    Usually in nested if statement there is an else part at the end which is executed in case all the if conditions evaluates to false.

    It will be written like this:

    if (average>79)

    { if (average<=89)

    { / *some block of the code to be executed in case the above two if conditions evaluate to true * / } }

    else

    { / /executed if both the above if conditions evaluate to false.}
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “How can the compound conditional expression ((average > 79 && average < = 89)) be written to eliminate the logical operator - without ...” in 📘 Chemistry if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers