Presentation is loading. Please wait.

Presentation is loading. Please wait.

CPS120: Introduction to Computer Science

Similar presentations


Presentation on theme: "CPS120: Introduction to Computer Science"— Presentation transcript:

1 CPS120: Introduction to Computer Science
File Processing: Basic Structure

2 File Structure

3 Basic Structure

4 Sequence Control Structures
Sequence control structures direct the order of program instructions. The fact that one instruction follows another—in sequence—establishes the control and order of operations.

5 Calculate Add 1 to Counter
A program can instruct a computer to perform mathematical operations. Add 1 to Counter

6 Store A program will often instruct a computer to store intermediate results. Place 1 in Counter

7 Compare and Branch A program can instruct a computer to compare two items and do something based on a match or mismatch which, in turn, redirect the sequence of programming instructions. There are two forms: IF-THEN IF-THEN-ELSE

8 IF-THEN false true Entry Exit True statement a Test condition p

9 IF-THEN-ELSE Entry Exit Test condition p “true” statement a
false true Entry Exit Test condition p “true” statement a “false” statement a

10 Iterate A program loop is a form of iteration. A computer can be instructed to repeat instructions under certain conditions.

11 Iteration Control Structures
Iteration control structures are looping mechanisms. Loops repeat an activity until stopped. The location of the stopping mechanism determines how the loop will work: Leading decisions Trailing decisions

12 Leading Decisions If the stop is at the beginning of the iteration, then the control is called a leading decision. The command DO WHILE performs the iteration and places the stop at the beginning.

13 DO WHILE Loop No Yes Entry Exit Test condition p Loop statement a

14 Trailing Decisions If the stop is at the end of the iteration, the control mechanism is called a trailing decision. The command DO UNTIL performs the iteration and puts the stop at the end of the loop.

15 DO UNTIL Loop No Yes Entry Test condition p Exit Loop statement a


Download ppt "CPS120: Introduction to Computer Science"

Similar presentations


Ads by Google