1 / 13

Test 2 review

Test 2 review. Tiffany Barnes 3/15/07. Top-down design. Break a program into parts=modules Draw a picture/hierarchy chart Fill in parts with pseudocode If modules are complex, repeat the process for each module. Modules. Self-contained, compact, performs a single task Part of a program

chas
Download Presentation

Test 2 review

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. Test 2 review Tiffany Barnes 3/15/07

  2. Top-down design • Break a program into parts=modules • Draw a picture/hierarchy chart • Fill in parts with pseudocode • If modules are complex, repeat the process for each module

  3. Modules • Self-contained, compact, performs a single task • Part of a program • Calling a module • Transfers control to the first line of the module • When it is complete, it returns to the statement right after the call

  4. Example • Problem: write a program that computes the avg. of three #s entered by the user • Parts • Display welcome message • Input data • Calculate Average • Output results

  5. Testing • Check for syntax & logic errors • Syntax errors • Violations of prog. language’s rules for statement structure • Logic errors • Failing to carry out the given task

  6. Flowcharts • Terminators (rounded box) • Process (Box) • I/O (parallelogram) • Decision (diamond) • Connector

  7. Control structures • Sequential (in sequence) • Loop (repetition) • Branch to previous step • Decision (selection) • Branch forward, causes some code to be skipped

  8. Operators • Arithmetic • +,-,*,/ • Logical • Not, And, Or • Relational: =, !=, <, >, <=, >= • Order: Arithmetic, relational, logical

  9. Defensive programming • Avoid division by zero • Avoid sqrt of neg number

  10. Loops • Pre-test: while • Test the condition before the lopp • Post-test: do-while • Test the stopping condition after the loop

  11. Loop control • Sentinel-value • Counter-controlled loops • Built-in: For • Can implement with a while loop

  12. Loop uses • Gathering input • Data validation • Computing sums and averages • Running total

  13. Nested loops • When one loop is inside another

More Related