Mar13 - CSE262 Programming Languages Instructor Dr Liang...

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

View Full Document Right Arrow Icon
CSE262: Programming Languages Instructor: Dr. Liang Cheng Department of Computer Science and Engineering Lehigh University March 13, 2007
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
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
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
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
Background image of page 5

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

View Full DocumentRight Arrow Icon
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
Background image of page 6
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
Background image of page 7

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

View Full DocumentRight Arrow Icon
Instructor: Dr. Liang Cheng CSE262: Programming Languages 03/13/07 Short Circuit Evaluation ± C, C++, and Java: use short-circuit
Background image of page 8
Image of page 9
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 Right Arrow Icon
Ask a homework question - tutors are online