More on the Repetition Structure - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

More on the Repetition Structure

Description:

requires four memory locations to store values of its input and output items. Use int data type for the variables that store: multiplicand. multiplier. Product ... – PowerPoint PPT presentation

Number of Views:50
Avg rating:3.0/5.0
Slides: 18
Provided by: www2Pie
Category:

less

Transcript and Presenter's Notes

Title: More on the Repetition Structure


1
More on the Repetition Structure
  • Tutorial 9

2
Objectives
  • Show the posttest repetition structure in
    pseudocode and in a flowchart
  • Code a posttest loop using the C do statement
  • Nest repetition structures

3
Concept Lesson
4
Posttest Loops
  • Condition is evaluated with each repetition, or
    iteration, of the loop
  • Evaluation occurs after the instructions within
    the loop are processed

5
Posttest Loops
6
Coding the Posttest Loop
  • In the do while statement, the programmer must
    supply the loop condition to be evaluated
  • Loop condition
  • must be a Boolean expression (true or false)
  • can contain variables, constants, functions,
    methods, arithmetic operators, comparison
    operators, and logical operators
  • Programmer must also supply statements to be
    processed when loop condition evaluates to true
  • If more than one statement needs to be processed,
    they must be entered as a statement block

7
Syntax of the C do while Statement
8
Nested Repetition Structures
  • Inner loop - placed entirely within another loop,
    called the outer loop

9
Nested Loops Used by a Clock
10
Application Lesson
11
Sample Multiplication Table for the Number 6
12
IPO Chart for the Multiplication Table Problem
13
Data for Desk-checking
  • Data for first desk-check
  • Multiplicand 6
  • Answer to another table? question Y
  • Data for second desk-check
  • Multiplicand 2
  • Answer to another table? question N

14
Completed Desk-check Table for the Multiplication
Table Algorithm
15
Coding the Multiplication Table Algorithm
  • Multiplication table program
  • requires four memory locations to store values of
    its input and output items
  • Use int data type for the variables that store
  • multiplicand
  • multiplier
  • Product
  • Use String data type for variable that stores the
    answer to the another table? question

16
Completed Desk-Check Table
17
Summary
  • Posttest repetition structure evaluate condition
    after loop body
  • Pseudocode
  • Flowchart
  • Code using do statement
  • Work with nested repetition structures
  • Make sure outer loop completely contains inner
    loop
Write a Comment
User Comments (0)
About PowerShow.com