1 / 10

Flow of Control

INFSY 307 C++. Flow of Control. Flow of Control: order in which statements are performed. Sequence: one after the other Selection: selects a path based upon action Iteration: repetition. CONTROL STRUCTURES. Sequence.

gwyn
Download Presentation

Flow of Control

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. INFSY 307 C++ Flow of Control

  2. Flow of Control: order in which statements are performed

  3. Sequence: one after the other • Selection: selects a path • based upon action • Iteration: repetition CONTROL STRUCTURES

  4. Sequence • One immediately following the other • Ordered flow of program logic • All programs follow this order unless directed to proceed in another manner

  5. Selection(Branching alters flow of control) If (logical expression) { statement(s); }

  6. Selection (Continued) If (logical expression) { statement(s); } else { statement; }

  7. Selection Example If (hours <= 40.0) { pay = rate * hours; } else { pay = rate * (40.0 + (hours - 40.0) * 1.5); } cout<<pay; //assume all types are float

  8. Selection • Only one of the two branches is executed • If the comparison is true, the first statement(s) are executed • If the comparison is false, the second statement(s) are executed

  9. Comparison Operators

  10. Let’s Try • Page 79 Savitch • #17 • #18

More Related