Fourth Quarter.  Involves loops or cycles ◦ Loops: means that a process may be repeated as long as certain condition remains true or remains false. ◦

Slides:



Advertisements
Similar presentations
How SAS implements structured programming constructs
Advertisements

CS107 Introduction to Computer Science Lecture 3, 4 An Introduction to Algorithms: Loops.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
CHAPTER 5: Repetition Control Structure. Objectives  To develop algorithms that use DOWHILE and REPEAT.. UNTIL structures  Introduce a pseudocode for.
UNIT 3 PROBLEM SOLVING WITH LOOP AND CASE LOGIC STRUCTURE
CS0004: Introduction to Programming Repetition – Do Loops.
Repeating Actions While and For Loops
Executes a statement or statements for a number of times – iteration. Syntax for(initialize; test; increment) { // statements to be executed } Initial.
Loops Counting down from N to 1 in assembly we used JUMP statements to repeat previous instructions thus looping READ LOOP: WRITE SUB decrement JPOSLOOP.
Iteration (Looping Constructs in VB) Iteration: Groups of statements which are repeatedly executed until a certain test is satisfied Carrying out Iteration.
1 10/20/08CS150 Introduction to Computer Science 1 do/while and Nested Loops Section 5.5 & 5.11.
Introduction to Computing Dr. Nadeem A Khan. Lecture 4.
Program Design and Development
Chapter 4 Loops and Character Manipulation Dr. Ali Can Takinacı İstanbul Technical University Faculty of Naval Architecture and Ocean Engineering İstanbul.
Computer Programming 1 Repetition. Computer Programming 2 Objectives Repetition structures Study while and do loops Examine for loops A practical example.
Loops Repetition Statements. Repetition statements allow us to execute a statement multiple times Often they are referred to as loops Like conditional.
© 2004 Pearson Addison-Wesley. All rights reserved5-1 Iterations/ Loops The while Statement Other Repetition Statements.
Chapter 6 - Visual Basic Schneider
Repetition Statements Repeating an Action A specified number of times While a Condition is True Until a Condition is True.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Six Repeating Program Instructions.
Chapter 12: How Long Can This Go On?
1 CC111 Lec9 : Visual Basic Visual Basic (3) Lecture 9.
ENGR 112 Decision Structures.
Repetition & Loops. One of the BIG advantages of a computer: ­It can perform tasks over and over again, without getting bored or making mistakes (assuming.
 2002 Prentice Hall. All rights reserved. 1 Chapter 4: Control Structures: Part 1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures.
1 INF110 Visual Basic Programming AUBG Spring semester 2011 Reference books: Schneider D., An Introduction to Programming Using Visual Basic, Prentice.
CHAPTER SIX LOOPS © Prepared By: Razif Razali 1. FORMAT OR REFRESH!! WHAT HAVE WE LEARN? Differentiate between the types of selection structure? Which.
Visual Basic.net Loops. Used to do multiple executions of the same block of code Do while loops Do until loops For next loops.
1 09/20/04CS150 Introduction to Computer Science 1 Let ’ s all Repeat Together.
An Introduction to Programming with C++ Sixth Edition Chapter 7 The Repetition Structure.
COMPUTER PROGRAMMING. Iteration structures (loops) There may be a situation when you need to execute a block of code several number of times. In general,
Visual Basic Programming
Lecture 4: Calculating by Iterating. The while Repetition Statement Repetition structure Programmer specifies an action to be repeated while some condition.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements I.
A loop is a repetition control structure. body - statements to be repeated control statement - decides whether another repetition needs to be made leading.
Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Lecture 9 & 10 Repetition Statements.
1 Chapter 9. To familiarize you with  Simple PERFORM  How PERFORM statements are used for iteration  Options available with PERFORM 2.
CS 100 Introduction to Computing Seminar October 7, 2015.
ITERATIVE STATEMENTS. Definition Iterative statements (loops) allow a set of instruction to be executed or performed several until condition are met.
Control Structures RepetitionorIterationorLooping Part I.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
Tutorial 6: The Repetition Structure1 Tutorial 6 The Repetition Structure.
Controlling Program Flow with Looping Structures
REPETITION STATEMENTS - Part1  Also called LOOP STATEMENTS OR LOOP STRUCTURES 1 C++ Statements that repeat one or more actions while some condition is.
Topic: Control Statements. Recap of Sequence Control Structure Write a program that accepts the basic salary and allowance amount for an employee and.
ARITHMETIC OPERATORS COMPARISON/RELATIO NAL OPERATORS LOGIC OPERATORS ()Parenthesis>Greater than &&And ^Exponentiation=>=
Chapter 7: The Repetition Structure Introduction to Programming with C++ Fourth Edition.
ICS124 Session 9 Flowcharting 1. By the end of this section the student will be able to:  Name the three structures of the Structure Theorem  Identify.
Dani Vainstein1 VBScript Session 5. Dani Vainstein2 What we learn last session? Branching Branching using If … Then … Else statement. Branching using.
Computer Program Flow Control structures determine the order of instruction execution: 1. sequential, where instructions are executed in order 2. conditional,
Introduction to Programming G50PRO University of Nottingham Unit 6 : Control Flow Statements 2 Paul Tennent
Loops ( while and for ) CSE 1310 – Introduction to Computers and Programming Alexandra Stefan 1.
Loops causes program to execute the certain block of code repeatedly until some conditions are satisfied. Suppose you want to execute some code/s 10 times.
Program design Program Design Process has 2 phases:
UNIT 5 Lesson 15 Looping.
Ch 7: JavaScript Control Statements I.
JavaScript: Control Statements.
Chapter 6 – Repetition 6.1 Do Loops 6.2 For...Next Loops
CPS120: Introduction to Computer Science
Outline Altering flow of control Boolean expressions
MSIS 655 Advanced Business Applications Programming
Structured Program
Chapter (3) - Looping Questions.
Iteration: Beyond the Basic PERFORM
Fundamentals of visual basic
ICT Programming Lesson 3:
Chapter 4: Repetition Structures: Looping
Prepared By: Deborah Becker
Conditional Loops Counted Loops
Presentation transcript:

Fourth Quarter

 Involves loops or cycles ◦ Loops: means that a process may be repeated as long as certain condition remains true or remains false. ◦ Means “multiple processing”  Provides means of repeating a part of instruction without rewriting the part again and again.

 Body of the Loop : Set of statements which is repeated.  Loop Exit Condition: condition to be tested before each repetition.

 Start : the starting or the beginning point of the loop.  One may start with first or the last record in the file.

Step : the manner on how the records are to be processed in the given file. Proper sequencing is needed (ascending or descending).

Stop : the ending point. It is normally represented in a form of a conditional expression, thus, a decision symbol is used in the flowchart

 Is a variable that defines the starting, ending point and step of a looping statement.  It should be a variable that will uniquely identify all the records in the file.  It is a representation of a field in the record. The shorter the value, the better is the field

 Draw a flowchart that will read the grades in PT, CS and QS of student. Compute the average of the student. Print the name and the computed average.  Input :  Process:  Output:  Will there be multiple processing? How many times the inputting, processing and outputting will be performed? WHY?

 Draw a flowchart that will read the grades in PT, CS and QS of all the students in the class of II - ____. Compute the average of all the students. Print the names and the computed averages.  Input :  Process:  Output:  Will there be multiple processing? How many times the inputting, processing and outputting will be performed? WHY?

 Are used to literally count the number of times a portion of the flowchart is traced.  Need to be initialized / prepared prior to its use or application.  The operation involved is “addition”  The increment value is a constant  Example: C = C + 1 Increment Value Current Value New Value

 A numerical value that collects the result of a repeated mathematical operation.  Used to keep a running total of an item / the operation involved is “addition”.  Need to be initialized / prepared prior to its use or application.  The incremental value is a “variable” (subjected to change)  Example: S = S + N Increment Value  Current Value New Value

 Executes a group of instructions repeatedly  Has 3 Structures: ◦ For ……. Next ◦ Do …….. Loop : has three types:  Do While …. Loop  Do Until …. Loop  Do …… Loop while ◦ While ….. Wend

 Executes a section of the code a specified number of times.  Begins with the “for” statement and ends with the “next” statement.  Can only be used if the programmer knows the number of times the loop must be performed prior to its execution.

For = to Step Next

Dim UserName as string Dim times as integer Username = “Paul” Lbloutput.text = “ ” For times = 1 to 10 step 1 Lbloutput.text = lbloutput.text & chr(13) & Username Next times

Dim UserName as string Dim times as integer Username = “Paul” Lbloutput.text = “ ” For times = 1 to 10 Lbloutput.text = lbloutput.text & chr(13) & Username Next

For = to Step Next

Dim counter as integer Lbloutput.text = “” For counter = 10 to 1 step -1 lbloutput.text = lbloutput.text & chr(13) & counter Next

Dim counter as integer Lbloutput.text = “” For counter = 9 to 1 step -2 lbloutput.text = lbloutput.text & chr(13) & counter Next

 Most common statement among the do..loop statements  Test condition appears at the TOP of the loop ◦ As long as the test condition is TRUE, the block of code in the body of the loop will be continuously executed ◦ When the test condition becomes FALSE, the loop terminates.  Condition before iteration

Do while Loop

Private Sub Command1_Click( ) Dim N As Integer N = 0 Do While N < 10 N = N + 1 Print N Loop End Sub

Private Sub Command1_Click( ) Dim N As Integer N = 0 Do While N < 10 N = N + 1 Print N Loop End Sub Loop Statement

 The test condition appears at the bottom of the loop.  When the test condition stays TRUE, the loop still executes until it becomes false  Condition after iteration

Do Loop while

Private Sub Command1_Click( ) Dim N As Integer N = 0 Do N = N + 1 Print N Loop While N < 10 End Sub

 Test condition also appears at the TOP of the LOOP.  Executes the block of statements as long as the test condition is FALSE

Do until Loop

Private Sub Command1_Click( ) Dim N As Integer N = 0 Do Until N >= 10 N = N + 1 Print N Loop End Sub

DO WHILE / DO UNTIL Display numbers from 1 to 10  Do While N < 10 N = N + 1 Print N Body of Loop will be executed as long as the condition is TRUE. Display numbers from 1 to 10  Do Until N >= 10 N = N + 1 Print N Body of Loop will be executed as long as the condition is FALSE.

Hands – On Session

a. Make a program that will display this output on the form: b. Make a program that will display “Patience is a Virtue” 5 times.

 Filenames: ◦ Activity No.1  4Act12CN ◦ Activity No.2  4Act22CN