Structured Programming The Basics - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Structured Programming The Basics

Description:

Structured Programming The Basics Control structures They control the order of execution What order statements will be done in, or whether they will be done at all ... – PowerPoint PPT presentation

Number of Views:149
Avg rating:3.0/5.0
Slides: 15
Provided by: Debb3188
Category:

less

Transcript and Presenter's Notes

Title: Structured Programming The Basics


1
Structured ProgrammingThe Basics

2
Control structures
  • They control the order of execution
  • What order statements will be done in, or whether
    they will be done at all (skipping)
  • Different from data structures which are ways
    to access data, to operate on it

3
Why do structured programming?
  • It's easier to understand code written using
    structured programming
  • Easier to test and debug code
  • Easier to modify and maintain code
  • Easier to work with other people to write large
    programs

4
4 Control Structures
  • Sequence
  • Selection
  • Iteration
  • Module

5
Guarantees for All Structures
  • ONE Entrance
  • ONE Exit

6
SEQUENCE
. . .
Statement 1
Statement 2
Statement 3
7
Guarantees for Sequences
  • Will execute the steps in the order given
  • Will not enter or leave sequence in mid-stream
  • Will not skip steps

8
SELECTION(branch)
IF Condition THEN Statement1 ELSE Statement2
True
Statements1
Statement
Condition
. . .
Statements2
False
9
Selection Guarantees
  • Control always enters through the condition /
    question
  • One branch or the other is executed, never both
    on one run
  • MUST execute one branch or the other
  • Processes in branches can be as large or small as
    you want
  • Do not write Dead Code!

10
Dead Code
11
LOOP(repetition)
WHILE Condition DO Statement1
False
. . .
Condition
True
12
Guarantees
  • Will go through test / condition at top to get
    into loop
  • ALL of body will be executed before test is done
    again
  • Body will be repeated until test is answered
    differently (NO)
  • Do not write Infinite Loops!

13
SUBPROGRAM(function)
. . .
SUBPROGRAM1
SUBPROGRAM1 a meaningful collection of
SEQUENCES, SELECTIONS, LOOPS, SUBPROGRAM
calls
14
Module Flow of control
Write a Comment
User Comments (0)
About PowerShow.com