Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSC115 Introduction to Computer Programming

Similar presentations


Presentation on theme: "CSC115 Introduction to Computer Programming"— Presentation transcript:

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

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

3 Loop Basic Idea (sequence diagram)

4 Loop Do Loop do while condition statements1 loop statements2
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 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 condition Yes Statements2

17 For loops

18 Exercises Exercises 18, 21, 22, page 185 Exercises 33, page 187


Download ppt "CSC115 Introduction to Computer Programming"

Similar presentations


Ads by Google