For Code Next For Code Next A loop is a segment of a code that repeats (changing slightly each time)

Slides:



Advertisements
Similar presentations
Programming In C++ Spring Semester 2013 Lecture 3 Programming In C++, Lecture 3 By Umer Rana.
Advertisements

Looping Structures: Do Loops
Do-while Loops Programming. COMP102 Prog Fundamentals I: do-while Loops /Slide 2 The do-while Statement l Syntax do action while (condition) l How it.
An Object-Oriented Approach to Programming Logic and Design
CS0004: Introduction to Programming Repetition – Do Loops.
Loops (Part 1) Computer Science Erwin High School Fall 2014.
Iteration (Looping Constructs in VB) Iteration: Groups of statements which are repeatedly executed until a certain test is satisfied Carrying out Iteration.
Do/Loops A loop repeats a series of instructions. An iteration is a single execution of the statement(s) in the loop. Used when the exact number of iterations.
Iteration (Looping Constructs in VB) Iteration: Groups of statements which are repeatedly executed until a certain test is satisfied Carrying out Iteration.
Do Loops A Do..Loop terminates based on a condition that is specified Execution of a Do..Loop continues while a condition is True or until a condition.
1 10/11/06CS150 Introduction to Computer Science 1 do/while and Nested Loops.
Chapter 5: Control Structures II (Repetition)
New Mexico Computer Science For All More Looping in NetLogo Maureen Psaila-Dombrowski.
Control Structures II. Why is Repetition Needed? There are many situations in which the same statements need to be executed several times. Example: Formulas.
Repetition Statements Repeating an Action A specified number of times While a Condition is True Until a Condition is True.
110-K1 Iterations (1) Up to now, need to call the procedure again (e.g. click again on a command button) To repeat a piece of code: Can also use loops:
Flow of Control. 2 Control Structures Control structure: An instruction that determines the order in which other instructions in a program are executed.
Programming Fundamentals. Today’s lecture Decisions If else …… Switch Conditional Operators Logical Operators.
Institute for Personal Robots in Education (IPRE)‏ CSC 170 Computing: Science and Creativity.
CPS120 Introduction to Computer Science Iteration (Looping)
Logic Structure - focus on looping Please use speaker notes for additional information!
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
Repetition Statements.  Often it is necessary to repeat statements many times  Java has two ways of doing this  while statements  for statements.
Adding 10 items to a list… lstTest.Items.Add(1) lstTest.Items.Add(2) lstTest.Items.Add(3) lstTest.Items.Add(4) lstTest.Items.Add(5) lstTest.Items.Add(6)
Iterations Very Useful: Ability to repeat a block of code Example:
I Power Higher Computing Software Development High Level Language Constructs.
1 Chapter 9. To familiarize you with  Simple PERFORM  How PERFORM statements are used for iteration  Options available with PERFORM 2.
ITERATIVE STATEMENTS. Definition Iterative statements (loops) allow a set of instruction to be executed or performed several until condition are met.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
CPS120 Introduction to Computer Science Iteration (Looping)
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
CONTROL STATEMENTS LOOPS. WHY IS REPETITION NEEDED?  There are many situations in which the same statements need to be executed several times.  Example:
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Looping ROBERT REVAES. Logical Operators  && AND  Both have to be true for it to evaluate to be true.  || OR  One or the other has to be true for.
For…Next and Do...While Loops! Happy St. Patrick’s Day!
Introduction to Functions CSIS 1595: Fundamentals of Programming and Problem Solving 1.
GCSE Computing#BristolMet Session Objectives #23 MUST understand what is meant by the programming term iteration SHOULD describe methods of looping used.
9. ITERATIONS AND LOOP STRUCTURES Rocky K. C. Chang October 18, 2015 (Adapted from John Zelle’s slides)
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Lecture 7 – Repetition (Loop) FTMK, UTeM – Sem /2014.
Microsoft® Small Basic Conditions and Loops Estimated time to complete this lesson: 2 hours.
Loops Tonga Institute of Higher Education. Introduction Programs need to be able to execute tasks repeatedly. Use loops to repeat actions  For Loop 
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.
Follow up from lab See Magic8Ball.java Issues that you ran into.
Identify the Appropriate Method for Handling Repetition
Chapter 6: Loops.
Scratch: iteration / repetition / loops
Quick Test What do you mean by pre-test and post-test loops in C?
CiS 260: App Dev I Chapter 4: Control Structures II.
( Iteration / Repetition / Looping )
LESSON 11 – WHILE LOOPS UNIT 5 – 1/10/17.
For Loops October 12, 2017.
CPS120: Introduction to Computer Science
Chapter 6: Repetition Structures
Iteration: Beyond the Basic PERFORM
Iteration: Beyond the Basic PERFORM
IPC144 Introduction to Programming Using C Week 3 – Lesson 1
Algorithms Take a look at the worksheet. What do we already know, and what will we have to learn in this term?
IPC144 Introduction to Programming Using C Week 3 – Lesson 2
Three Special Structures – Case, Do While, and Do Until
Loops.
A LESSON IN LOOPING What is a loop?
Flow of Control.
Seating “chart” Front - Screen rows Back DOOR.
Loops.
Introduction to Repetition
Introduction to Repetition
LOOPS The loop is the control structure we use to specify that a statement or group of statements is to be repeatedly executed. Java provides three kinds.
CS2011 Introduction to Programming I Loop Statements (I)
Week 7: Computer Tools for Problem Solving and Critical Thinking
Presentation transcript:

For Code Next For Code Next A loop is a segment of a code that repeats (changing slightly each time)

Three types of loops 1. For - Do repeat a segment of code a specific number of times (eg. For counter = 1 to 10) We did this last lesson 2. While - Do loops perform the segment of code only if a condition is true. Eg. Keep repeating until a certain result is reached. 3. Repeat Until (or post-test) loops is like a While-Do loop but is only tested after the segment is executed once.

 A structured program is broken up into parts, or modules, that perform separate tasks. Module 1 Module 2 Module 2 Main Module is the control centre. (calls the other modules in when it needs to perform a task) Main Module is the control centre. (calls the other modules in when it needs to perform a task)

 Don’t use a variable across more than one module  Each module has only one entry and exit point.

 Structure Charts