answersLogoWhite

0

Expressions are evaluated according to the language grammar. Operator precedence and associativity are derived from the grammar in order to aid our understanding, however the order of evaluation is independent of both because the C language standard does not specify operator precedence.

The general arithmetic rules of precedence hold for most expressions such that parenthesised operations take precedence over orders followed by multiplication/division operations and finally addition/subtraction operations (as per the PODMAS acronym).

Many of the more complex expressions we encounter can generally be evaluated according to the operator precedence table, which includes the associativity, such that operations with higher precedence are bound more tightly (as if with parenthesis) than those with lower precedence.

User Avatar

Wiki User

8y ago

Still curious? Ask our experts.

Chat with our AI personalities

TaigaTaiga
Every great hero faces trials, and you—yes, YOU—are no exception!
Chat with Taiga
LaoLao
The path is yours to walk; I am only here to hold up a mirror.
Chat with Lao
MaxineMaxine
I respect you enough to keep it real.
Chat with Maxine

Add your answer:

Earn +20 pts
Q: How do you evaluate an expression in hierarchy of operations?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Define an expression that evaluates to true when i equals j?

In Java, or C, the expression is simply:i == jIf the two are equal, this expression will evaluate to true; if not, it will evaluate to false.In Java, or C, the expression is simply:i == jIf the two are equal, this expression will evaluate to true; if not, it will evaluate to false.In Java, or C, the expression is simply:i == jIf the two are equal, this expression will evaluate to true; if not, it will evaluate to false.In Java, or C, the expression is simply:i == jIf the two are equal, this expression will evaluate to true; if not, it will evaluate to false.


What do you mean by Hierarchy in C language?

The preference in which arithematic operations are performed in an arithematic expression is called as Hierarchy of operations.Its very important in C Programming to predefine the Hierarchy of operations to the C compiler in order to solve the given arithematic expression correctly.e.g.: If a programmer wishes to perform ,z=a+b/c;it may beinterpretedas z=(a+b)/c or z=a+(b/c).and if a=3,b=6,c=2 then using the same expression we will obtain two differentanswersas z=4.5 or z=6.To avoid this condition we must be aware of hierarchy of operations used in C programming.In arithematic expressions scanning is always done from left to right.The priority of operations is as shown below,PriorityOperatorsFirstParenthesisos brackets()SecondMultiplication & DivisionThirdAddition & SubtractionFourthAssignment i.e.=If we consider the logical operators used in C language,the operator precedence will be like;OperatorsType!Logical NOT* / %Arithmetic and moulus+ -AritmeticRelational== !=Relational&&Logical ANDLogical OR=AssignmentIn the tables above,the higher the position of an operator,higher is its priority.


How do you Evaluate the expression 32-6 plus 5x4?

46


Evaluate the expression 12?

Constant values are expressions as well, still I don't think they are so hard to evaluate... well, in this case it is twelve


When you need to satisfy two or more criteria to initiate an event in a program you must make sure that the second decision is made entirely independently of the first decision?

Evaluate the criteria before executing the conditional expression. In pseudocode:result1 = evaluate( criteria1 );result2 = evaluate( criteria2 );if( result1 && result2 ) initiate_event;Note that this is not the same as the following:if( evaluate( criteria1 ) && evaluate( criteria2 )) initiate_event;If the evaluation of criteria1 fails for any reason, then the whole expression fails and criteria2 is never evaluated. so if the evaluations must be done independently of each other, then they must be done prior to the conditional expression, storing the results for use in the conditional expression.