Introducing Do While & Do Until Loops & Repetition Statements

Slides:



Advertisements
Similar presentations
Lists, Loops, Validation, and More
Advertisements

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 5- 1 STARTING OUT WITH Visual Basic 2008 FOURTH EDITION Tony Gaddis.
Repetition Statements Perform the same task repeatedly Allow the computer to do the tedious, boring things.
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.
Lecture Notes 3 Loops (Repetition)
CHAPTER 5: Repetition Control Structure. Objectives  To develop algorithms that use DOWHILE and REPEAT.. UNTIL structures  Introduce a pseudocode for.
Microsoft Visual Basic: Reloaded Chapter Six Repeating Program Instructions.
1 Repetition structures Overview while statement for statement do while statement.
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
Loop Statements (Iteration). Iteration  A portion of a program that repeats a statement or group of statements is called a loop.  Each repetition of.
Chapter 6 - Visual Basic Schneider
New Mexico Computer Science For All More Looping in NetLogo Maureen Psaila-Dombrowski.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 6 – Car Payment Calculator Application: Introducing.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 9 Car Payment Calculator Application Introducing the Do While...Loop and Do Until...Loop.
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:
For Loops. Challenge: Racer ● Simulate a race that says “Now on lap X” for 10 laps. ● Make X vary, so it says 1, then 2, then 3 ● Use only one output.
08/10/ Iteration Loops For … To … Next. 208/10/2015 Learning Objectives Define a program loop. State when a loop will end. State when the For.
Copyright © 2001 by Wiley. All rights reserved. Chapter 5: The Repetition Process in Visual Basic Event Driven Loops Determinate Loops Indeterminate Loops.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 6 – Car Payment Calculator Application: Introducing.
1 Week 6 The Repetition Structure. 2 The Repetition Structure (Looping) Lesson A Objectives After completing this lesson, you will be able to:  Code.
© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 8: Chapter 5: Slide 1 Unit 8 List Boxes and the Do While Looping Structure.
Statements That Repeat. For...Next Loop Structure For counter = start To end Step increment statements Next counter Where Counter is tested to see if.
CSC 162 Visual Basic I Programming. Repetition Structures Pretest Loop –Exit condition is tested before the body of code is executed Posttest Loop –Exit.
Tutorial 6 The Repetition Structure
Chapter 4 Looping Statements Adapted From: Starting Out with Visual Basic 2008 (Pearson)
Visual Basic.net Loops. Used to do multiple executions of the same block of code Do while loops Do until loops For next loops.
Control Structures II Repetition (Loops). Why Is Repetition Needed? How can you solve the following problem: What is the sum of all the numbers from 1.
Lecture 4: Calculating by Iterating. The while Repetition Statement Repetition structure Programmer specifies an action to be repeated while some condition.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Class Average Application Introducing the Do...Loop While and Do...Loop Until.
CS 101 Test 2 Study Guide Acronyms RAD - Rapid Application Development IDE - Integrated Development Environment GUI - Graphical User Interface VB - Visual.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
Conditional Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Counting Loops.
Looping Structures Do Loops, For Next Do...Loop While structures check the condition after executing the code and repeat a code block until the test.
For…Next Loops, Checked List Boxes, and Combo Boxes Chapter 5.
Copyright © 2012 Pearson Education, Inc. Chapter 5: Loops.
Tutorial 6: The Repetition Structure1 Tutorial 6 The Repetition Structure.
Visual Basic.NET BASICS Lesson 11 List Boxes, For Next Loops, and Label Settings.
CSC 162 Visual Basic I Programming. Repetition Structures Pretest Loop –Exit condition is tested before the body of code is executed Posttest Loop –Exit.
Controlling Program Flow with Looping Structures
Lecture 7: Menus and getting input. switch Multiple-selection Statement switch Useful when a variable or expression is tested for all the values it can.
CSD 340 (Blum)1 For Loops See Beginning JavaScript (Paul Wilton) p. 87.
BO65: PROGRAMMING ITERATION 1. Starter  Write down what you think the code below outputs on screen: Dim intCounter as integer intCounter = 0 Do while.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Loop Blocks Chapter 6 Part A. Program Blocks 1.Actions- commands, messages, methods 2.Branches- decisions to be made 3.Loops- actions to be repeated.
5a – While Loops Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
Dani Vainstein1 VBScript Session 5. Dani Vainstein2 What we learn last session? Branching Branching using If … Then … Else statement. Branching using.
Loops ISYS 350. Write a Program that asks user to enter any numbers and displays the largest number Process: Largest = the first number Get the next number.
Chapter 6 Controlling Program Flow with Looping Structures.
CE En 270 Brigham Young University Norm Jones
while Repetition Structure
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
Tutorial 10 – Class Average Application Introducing the Do…Loop While and Do…Loop Until Repetition Statements Outline Test-Driving the Class Average.
Tutorial 9 - Car Payment Calculator Application Introducing the while Repetition Statement Outline 9.1 Test-Driving the Car Payment Calculator Application.
Lesson 05: Iterations Class Chat: Attendance: Participation
Chapter 5: Loops and Files.
Chapter 6 – Repetition 6.1 Do Loops 6.2 For...Next Loops
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
Alice in Action with Java
حلقات التكرار.
البرمجة بلغة الفيجول بيسك ستوديو
Chapter (3) - Looping Questions.
Iteration: Beyond the Basic PERFORM
Do … Loop Until (condition is true)
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Introduction to Repetition Structures
CSC1401 Manipulating Pictures 2
Chapter 2 Sets Active Learning Lecture Slides
Presentation transcript:

Introducing Do While & Do Until Loops & Repetition Statements Tutorial 9 Introducing Do While & Do Until Loops & Repetition Statements

Do While Loop Do While [condition] action(s) Loop intCounter = 0 Do While (intCounter < 10) intSumOfNumbersUpto10 += intCounter intCounter += 1 Continue 

Repeats the actions as long as the condition is true The condition must change, otherwise infinite loop will occur. Within the loop add code(s) to change the condition that eventually become false

Do Until Loop Do Until [condition] action(s) Loop intCounter = 0 Do Until (intCounter >= 10) intSumOfNumbersUpto10 += intCounter intCounter += 1 Continue 

Repeats the actions as long as the condition is false The condition must change, otherwise infinite loop will occur. Within the loop add code(s) to change the condition that eventually become true

Coding with ListBox Remove items in the ListBox lstStudents.Items.Clear( ) Class.SubClass.Behavior or Add items to the ListBox lstStudents.Items.Add (“Name” & ControlChars.Tab & ControlChars.Tab & “Course”)

Example Dim intCounter As Integer = 1 Dim intSumOfNumbersUpto10 As Integer = 0 Do While (intCounter < 10) intSumOfNumbersUpto10 += intCounter lstNumbersUpto10.Items.Add(“Number “ & intCounter & ControlChars.Tab & intSumOfNumbersUpto10) intCounter += 1 Loop