Mar15 - 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 15, 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/15/07 Outline ± Recap ± Statement-Level Control Structures (Chapter 8) ± Scheme language (Chapter 15) ± Summary
Background image of page 2
Instructor: Dr. Liang Cheng CSE262: Programming Languages 03/15/07 Statement-Level Control Structures ± A statement-level control structure is a control statement and the statements whose execution it controls ± Other levels of control flow ± All flowcharts can be coded with only two-way selections and pretest logical loops
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/15/07 Two-Way Selection Statements ± A design issue ± Nested two-way selectors if . .. if . .. ... else . .. ± Which if gets the else ? ± Java: static semantics rule - else goes with the nearest if ± ALGOL 60: disallow direct nesting (using begin/end pair) ± FORTRAN 90 and Ada: closing special words (using endif)
Background image of page 4
Instructor: Dr. Liang Cheng CSE262: Programming Languages 03/15/07 Multiple-Way Selection Statements ± Modern language examples 1. Pascal case expression of constant_list_1 : statement_1; ... constant_list_n : statement_n end 2. The C, C++, and Java switch switch (expression) { constant_expression_1 : statement_1; ... constant_expression_n : statement_n; [ default: statement_n+1;] }
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/15/07 Iterative Statements ± The repeated execution of a statement or compound statements is accomplished either by iteration or recursion ± General design issues for iteration control statements 1. How is iteration controlled? Counter-controlled loops, logically-controlled loops, or iteration based on data structures 2. Where is the control mechanism in the loop? At the beginning, ending, or user-located
Background image of page 6
Instructor: Dr. Liang Cheng CSE262: Programming Languages 03/15/07 Counter-controlled Loops ± FORTRAN 90 [name:] DO variable = initial, terminal [, stepsize] END DO [name] ± Pascal for variable := initial (to | downto) final do statement ± C/C++ ± for ([expr_1] ; [expr_2] ; [expr_3]) statement
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/15/07 Logically-controlled Loops ± Design issues: pretest or posttest ± Pascal has separate pretest and posttest logical
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.

Page1 / 32

Mar15 - 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