CSC115 Introduction to Computer Programming - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

CSC115 Introduction to Computer Programming

Description:

check condition ... check condition and stop because the event occurs ... Write down the initialization and check the change in the process body to ensure ... – PowerPoint PPT presentation

Number of Views:16
Avg rating:3.0/5.0
Slides: 19
Provided by: pc6132
Learn more at: http://www.cs.wcupa.edu
Category:

less

Transcript and Presenter's Notes

Title: CSC115 Introduction to Computer Programming


1
CSC115 Introduction to Computer Programming
  • Zhen Jiang
  • Dept. of Computer Science
  • West Chester University
  • West Chester, PA 19383
  • zjiang_at_wcupa.edu

2
Table of Contents
  • Structure
  • Loop
  • Function
  • Interesting features
  • Graphics
  • Other tools

3
Loop
  • Basic Idea (sequence diagram)

4
Loop
  • Do Loop
  • Do while Loop
  • do while condition
  • statements1
  • loop
  • statements2

5
No
Yes
condition
Statements1
Statements2
6
  • Counter Control Loop
  • Repetition body
  • Condition
  • Increment and initialization

7
  • Exercises
  • Example 1, page 165

8
  • How to get a result of a loop program by hand
  • Counter control loop see a counter
    (initialization, increment, condition)
  • Repeat the body that many times
  • For each statement, check the change of variable
    value.

9
  • How to develop your own loop program
  • Counter control loop know what is the body
    process and how many times it repeats.
  • Following the format of counter control loop,
    write down these in such an order condition,
    increment, initialization.
  • Find the change of body for each time it repeats,
    compare it with the change of counter, determine
    the relationship of them, form the statements of
    body.

10
  • Event Control Loop
  • Repetition body
  • Event condition
  • Initialization

11
  • Exercises
  • Exercises 25 (with 25 students), 23, 25, page 176

12
  • How to get a result of an event control loop
    program by hand
  • check condition
  • If needs another round, repeat the body and check
    the change of variable value for each statement.
    Otherwise, stop.
  • check condition
  • If needs another round, repeat the body and check
    the change of variable value for each statement.
    Otherwise, stop.
  • check condition and stop because the event occurs

13
  • How to develop your own loop program (Simple
    version)
  • Event control loop not counter control loop
  • EOF

14
  • How to develop your own loop program
  • Event control loop not counter control loop
  • Write down the condition to describe when the
    event occurs.
  • Write down the process body.
  • Write down the initialization and check the
    change in the process body to ensure the event
    will occur finally and make the condition false.

15
  • Do Until Loop
  • Do
  • statements1
  • Until condition
  • statements2

16
Statements1
No
Yes
condition
Statements2
17
  • For loops

18
  • Exercises
  • Exercises 18, 21, 22, page 185
  • Exercises 33, page 187
  • Exercises 36, page 188
Write a Comment
User Comments (0)
About PowerShow.com