Introduction to basic programming repetition

17
Introduction to BASIC Programming Repetition Flowchart

description

Reviewer Repetition or looping

Transcript of Introduction to basic programming repetition

  • 1. Introduction to BASIC Programming
    RepetitionFlowchart

2. Structure
Sequence
Selection
Repetition
3. SEQUENCE
In a computer program or an algorithm,sequence involves simple steps which are to be executed one after the other.
4. Make a Flowchart to add two numbers and print the result.
START
S=0: n1=0: n2=0
n1, n2
S= n1+n2
Print S
STOP
5. DECISION structure
6. SELECTION
Selection is used in a computer program or algorithm to determine which particular step or set of steps is to be executed
7. Example
Compute the sum of x and y if x is greater than y, other wise print d as their difference.
Draw a flowchart to find the largest of three numbers A, B, and C.
8. Repetition
9. Repetition
Repetition allows for a portion of an algorithm or computer program to be done any number of times dependent on some condition being met.
An occurrence of repetition is usually known as a loop.
Thebody of the loop is executed repeatedly while the termination condition is true.
10. Repetition (Pre-Test Structure)
A pre-tested loop is so named because the condition has to be met atthe very beginning of the loop.
This construct is often called a guarded loop.
11. Repetition (Post-Test Structure)

  • A post-tested loop executes the body of the loop before testing the termination condition.

12. This construct is often referred to as an unguarded loop.