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?

Expert's answer

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.


LATEST TUTORIALS
APPROVED BY CLIENTS