# Lecture22 - Todays Agenda Precedence and Associativity of...

This preview shows pages 1–5. Sign up to view the full content.

1 Computer Programming I TA C162 . 20/01/06 Today’s Agenda Precedence and Associativity of Operators Examples More about Input and Output Formatted Input Formatted Output Examples

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2 Computer Programming I TA C162 . 20/01/06 What is Precedence and Associativity? Operators have rules that are used to determine how expressions are evaluated. Precedence and associativity deal with the evaluation order within expressions Precedence rules specify the order in which operators of different precedence level are evaluated Associativity rules decides the order in which multiple occurrences of the same level operator are applied.
3 Computer Programming I TA C162 . 20/01/06 Rules of Evaluation of Expression 1. First, parenthesized sub expression from left to right are evaluated. 2. If parentheses are nested, the evaluation begins with the innermost sub expression. 3. The precedence rule is applied in determining the order of application of operators in evaluating sub-expressions. 4. The associativity rule is applied when two or more operators of the same precedence level appear in a sub expression.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
4 Computer Programming I TA C162 . 20/01/06 Precedence of Arithmetic Operators Two priority levels of operators High priority *, /, % Low priority + - Consider the expression 1+2*3 * has higher priority than + So the value of the expression is 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 18

Lecture22 - Todays Agenda Precedence and Associativity of...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online