# Mar13 - CSE262 Programming Languages Instructor Dr Liang...

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

CSE262: Programming Languages Instructor: Dr. Liang Cheng Department of Computer Science and Engineering Lehigh University March 13, 2007

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

View Full Document
Instructor: Dr. Liang Cheng CSE262: Programming Languages 03/13/07 Outline ± Recap ± Expressions and assignment statements (Chapter 7) ± Statement-level control structures (Chapter 8) ± Summary and homework
Instructor: Dr. Liang Cheng CSE262: Programming Languages 03/13/07 Chapter 7 Topics ± Arithmetic expressions ± Overloaded operators ± Relational and boolean expressions ± Short-circuit evaluation ± Type conversions ± Operands with mixed types ± Assignment statements ± Mixed-mode assignment ± Arithmetic expressions ± Relational and boolean expressions ± Short-circuit evaluation ± Type conversions ± Assignment statements ± Mixed-mode assignment

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

View Full Document
Instructor: Dr. Liang Cheng CSE262: Programming Languages 03/13/07 Arithmetic Expressions ± Arithmetic expressions may consist of: ± Operators ± Unary, binary, and ternary operators ± Precedence rules and associativity rules ± Operands ± Order of operand evaluation ± Parentheses ± Function calls ± Arithmetic expressions ± Relational and boolean expressions ± Short-circuit evaluation ± Type conversions ± Assignment statements ± Mixed-mode assignment
Instructor: Dr. Liang Cheng CSE262: Programming Languages 03/13/07 Relational and Boolean Expressions ± Relational expressions ± Use relational operators and operands of various types ± Operator symbols vary somewhat among languages (!=, /=, .NE., <>, # ) ± Evaluate to some Boolean representation ± Boolean expressions ± Operands are Boolean and the result is Boolean FORTRAN 77 FORTRAN 90 C Ada .AND. and && and .OR. or || or .NOT. not ! not ± Arithmetic expressions ± Relational and boolean expressions ± Short-circuit evaluation ± Type conversions ± Assignment statements ± Mixed-mode assignment

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

View Full Document
Instructor: Dr. Liang Cheng CSE262: Programming Languages 03/13/07 Relational and Boolean Expressions ± Precedence of all Ada operators: **, abs, not *, /, mod, rem unary -, + relops, in, not in and, or, xor, and then, or else ± C, C++, and Java have over 40 operators and at least 15 different levels of precedence
Instructor: Dr. Liang Cheng CSE262: Programming Languages 03/13/07 Short Circuit Evaluation ± The results is determined without evaluating all of the operands and/or operators ± Assume a language did not use short-circuit evaluation: a table look-up example index = 1; while (index <= length) && (LIST[index] != value) index++; ± Short-circuit evaluation exposes the potential problem of side effects in expressions (a > b) || (b++ / 3) ± Arithmetic expressions ± Relational and boolean expressions ± Short-circuit evaluation ± Type conversions ± Assignment statements ± Mixed-mode assignment

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

View Full Document
Instructor: Dr. Liang Cheng CSE262: Programming Languages 03/13/07 Short Circuit Evaluation ± C, C++, and Java: use short-circuit
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 08/06/2008 for the course CSE 262 taught by Professor Cheng during the Spring '07 term at Lehigh University .

### Page1 / 41

Mar13 - CSE262 Programming Languages Instructor Dr Liang...

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

View Full Document
Ask a homework question - tutors are online