Introduction to basic programming repetition
Upcoming SlideShare
Loading in...5
×
 

Introduction to basic programming repetition

on

  • 4,602 views

Reviewer Repetition or looping

Reviewer Repetition or looping

Statistics

Views

Total Views
4,602
Views on SlideShare
4,583
Embed Views
19

Actions

Likes
0
Downloads
71
Comments
0

1 Embed 19

http://www.sirjordz.moodlehub.com 19

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Introduction to basic programming repetition Introduction to basic programming repetition Presentation Transcript

  • Introduction to BASIC Programming
    RepetitionFlowchart
  • Structure
    Sequence
    Selection
    Repetition
  • SEQUENCE
    In a computer program or an algorithm, sequence involves simple steps which are to be executed one after the other.
  • 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
  • DECISION structure
  • SELECTION
    Selection is used in a computer program or algorithm to determine which particular step or set of steps is to be executed
  • 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.
  • Repetition
  • 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.
  • 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.
  • Repetition (Post-Test Structure)
    • A post-tested loop executes the body of the loop before testing the termination condition.
    • This construct is often referred to as an unguarded loop.
  • Variables (in memory):
    Num [ 4 ]
    Result [ ]
    Count [ ]
    Input:
    Num <- 4
    Enter a Number => 4
    Count = 4
    4 > 0 ? => YES
    Count = 3
    3 > 0 ? => YES
    Count = 2
    2 > 0 ? => YES
    Count = 1
    1 > 0 ? => YES
    Count = 0
    0 > 0 ? => NO
    Example:
    What is the output of the following flowchart when the input is Num= 4
    Variables (in memory):
    Num [ 4 ]
    Result [ 0 ]
    Count [ 4 ]
    Variables (in memory):
    Num [ 4 ]
    Result [ 7 ] 4 + 3
    Count [ 2 ] 3 - 1
    Variables (in memory):
    Num [ 4 ]
    Result [ 9 ] 7 + 2
    Count [ 1 ] 2 - 1
    Variables (in memory):
    Num [ ]
    Result [ ]
    Count [ ]
    Variables (in memory):
    Num [ 4 ]
    Result [ 10] 9 + 1
    Count [ 0 ] 1 - 1
    Variables (in memory):
    Num [ 4 ]
    Result [ 4 ] 0 + 4
    Count [ 3 ] 4 - 1
    Count: 4
    Count: 3
    Count: 2
    Count: 1
    Count: 0
    Result: 10
  • Assignment
  • Review for the Long Quiz #3
  • Selection (Structure)
    Determine if the input age is qualified to vote or not. If qualified, display “Qualified to vote!” if not, display “Too young!”
    Given a number, print the message “Positive”, “Negative” or “Neither”
  • 3. The V. Mapa High School is accepting freshmen who are not more than 15 years old. Given the students’ name and age, print “ACCEPTED” if it meets the ages Requirement otherwise print “Sorry”
  • 4. Due to your poor results in the examination, I decided to increase each one of you by 5 points. Input your grade and print the new grade. If the original grade exceeds 90, then it remains as is.