Answer to Question #185472 in C++ for Andrews Seadzi

Question #185472
  1. How you can improve the efficiency of a nested decision?
  2. When you combine AND and OR operators within the same statement, which takes precedence?
1
Expert's answer
2021-04-26T00:28:57-0400

Solution-1

In case of nested loops i.e. loops within loops having many conditions to be tested in each loopings, in that case, while evaluating two decisions, a decision must me choosen which of the decisions to make first. In fact, logically, in order of first, second and so on. AND expression must be evaluated first as it has higher precedence than OR condition.



Solution-2

Order of precedence in C/C++

Logical AND && Left to right

Logical OR || Left to right

This means that if logical AND and OR operators are in the same statement, then logical AND has more precedence than logical OR operator.


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS