Repetition Yonglei Tao. Display Numbers num = 1 lblDisplay.Text = num & ControlChars.NewLine num = 2 * 2 lblDisplay.Text = lblDisplay.Text & num & ControlChars.NewLine.

Slides:



Advertisements
Similar presentations
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 6 Repetition Statements.
Advertisements

Chapter 6 - VB 2005 by Schneider1 Do Loop Syntax Do While condition statement(s) Loop Condition is tested, If it is True, the loop is run. If it is False,
Chapter 4 Ch 1 – Introduction to Computers and Java Flow of Control Loops 1.
CS 4 Intro to Programming using Visual Basic Do Loops Patchrawat Uthaisombut University of Pittsburgh 1 based on lecture notes by D. Schneider.
Method main Point p1 = new Point(5, 6); Point p2 = new Point(10, 11); System.out.println(p1.getX()); System.out.println( Point.num );
……+(4n-3) = n(2n-1) P 1 = 1(2(1)-1)=1 check.
Chapter 04 (Part III) Control Statements: Part I.
The String Class Properties and Methods Chars(index) Method Dim strtest as string, strtwo as string strtest = “peanut butter” Lbldisplay.text = strtest.Chars(4)
1 10/20/08CS150 Introduction to Computer Science 1 do/while and Nested Loops Section 5.5 & 5.11.
Chapter seven review. What is the output of: Private Sub cmdButton_Click() Dim i As Integer, a(1 To 4) As integer Open "DATA.TXT" For Input As #1 For.
Section 2.6 Question 1. Section 2.6 Answer 1 Section 2.6 Question 2.
Arrays. What is the output of: Private Sub cmdButton_Click() Dim i As Integer, a(1 To 4) As integer Open "DATA.TXT" For Input As #1 For i = 1 To 4 Input.
LAB 10.
COMPE 111 Introduction to Computer Engineering Programming in Python Atılım University
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:
Chapter 5 Control Structures: Loops 5.1 The while Loop The while loop is probably the most frequently used loop construct. The while loop is a conditional.
Chapter 6 - VB 2005 by Schneider1 Chapter 6 – Repetition 6.1 Do While and Do Until Loops 6.2 Processing Lists of Data with Do Loops 6.3 For...Next Loops.
Chapter 71 Repetition - Do Loops n A Loops, is used to repeat a sequence of statements a number of time n There are two loops commands in Visual Basic.
1 09/20/04CS150 Introduction to Computer Science 1 Let ’ s all Repeat Together.
CMSC 104, Lecture 171 More Loops Topics l Counter-Controlled (Definite) Repetition l Event-Controlled (Indefinite) Repetition l for Loops l do-while Loops.
Repetition Structures Repetition Structures allow you to write programs that will repeat program steps multiple times. –Also called Loops –Counter controlled.
Chap 7- Control Structures : The WHILE Statement.
Count and add list of numbers From user input and from file.
Chapter 4 Practice cont.. Practice with nested loops 1.What will be the output of the following program segment: 1.for (int i = 1; i
Repetition Structures
CS 139-Programming Fundamentals Lecture 11B - Arrays Adapted from a presentation by Dr. Rahman Fall 2014.
CMSC 104, Version 9/011 More Loops Topics Counter-Controlled (Definite) Repetition Event-Controlled (Indefinite) Repetition for Loops do-while Loops Choosing.
1 do-while Statement 2 Do-While Statement Is a looping control structure in which the loop condition is tested after each iteration of the loop. SYNTAX.
Agenda Perform Quiz #1 (20 minutes) Loops –Introduction / Purpose –while loops Structure / Examples involving a while loop –do/while loops Structure /
Chapter six exercises
1 For Loops l From Chapter 9 l A shorthand way of coding count loops.
1 Looping Dale/Weems/Headington. 2 KA/JS/P Warning l Save your work often! l In the Khan Academy, JavaScript environment, infinite loops will lock up.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 14 Do It, Then Ask Permission.
Repetition loops Is a condition true? START END OF LOOP EXIT.
While loop Write a program that asks the user to enter a number, then displays whether this number is even or odd. The program repeats until the user quits.
EGR 115 Introduction to Computing for Engineers Loops and Vectorization – Part 1 Monday 13 Oct 2014 EGR 115 Introduction to Computing for Engineers.
Expressions Methods if else Statements Loops Potpourri.
Why Repetition? Read 8 real numbers and compute their average REAL X1, X2, X3, X4, X5, X6, X7, X8 REAL SUM, AVG READ *, X1, X2, X3, X4, X5, X6, X7, X8.
Computer Science 101 For Statement. For-Statement The For-Statement is a loop statement that is especially convenient for loops that are to be executed.
Visual Basic Declaring Variables Dim x as Integer = 0 In the statement above, x is being declared as an Integer (whole number) and is initialised.
Arrays. What is an array? An array is a collection of data types. For example, what if I wanted to 10 different integers? int num1; int num2; int num3;
FOR LOOP STRUCTURE For := to do eg. for I := 1 to 100 do begin writeln(‘This is a loop’); end;
EE 201 1C10-2 Spring 2012 LOOPS For.  Achieve Comprehension LOL of using Loops in programming. Class Learning Objectives 2C10-2 Spring 2012.
Unit-1 Introduction to Java
Repetition – For and Do While
Selection Structures (Part 1)
2008/10/22: Lecture 12 CMSC 104, Section 0101 John Y. Park
TK1114 Computer Programming
Introducing Do While & Do Until Loops & Repetition Statements
Chapter 6 – Repetition 6.1 Do Loops 6.2 For...Next Loops
Determinate Loops with the
Alice in Action with Java
Repetition and Loops while do while for continue break
More Loops.
2008/10/22: Lecture 12 CMSC 104, Section 0101 John Y. Park
More Loops.
CSC110 Fundamentals of CSC L3P2 TimesTable2 More with Less (Code)
More Loops Topics Counter-Controlled (Definite) Repetition
Fundamental Programming
More Loops Topics Counter-Controlled (Definite) Repetition
More Loops Topics Counter-Controlled (Definite) Repetition
More Loops Topics Counter-Controlled (Definite) Repetition
More Loops Topics Counter-Controlled (Definite) Repetition
Repetition (While Loop) LAB 9
Repetition - Counting and Accumulating
More Loops Topics Counter-Controlled (Definite) Repetition
More Loops Topics Counter-Controlled (Definite) Repetition
REPETITION Why Repetition?
Ch 3 Type Conversion Yonglei Tao.
Repetition – The For Loop
Presentation transcript:

Repetition Yonglei Tao

Display Numbers num = 1 lblDisplay.Text = num & ControlChars.NewLine num = 2 * 2 lblDisplay.Text = lblDisplay.Text & num & ControlChars.NewLine num = 3 * 3 lblDisplay.Text = lblDisplay.Text & num & ControlChars.NewLine num = 4 * 4 lblDisplay.Text = lblDisplay.Text & num & ControlChars.NewLine num = 5 * 5 lblDisplay.Text = lblDisplay.Text & num & ControlChars.NewLine lblDisplay

Display Numbers (Cont.) num = 1 * 1 lblDisplay.Text = lblDisplay.Text & num & ControlChars.NewLine num = 2 * 2 lblDisplay.Text = lblDisplay.Text & num & ControlChars.NewLine num = 3 * 3 lblDisplay.Text = lblDisplay.Text & num & ControlChars.NewLine num = 4 * 4 lblDisplay.Text = lblDisplay.Text & num & ControlChars.NewLine num = 5 * 5 lblDisplay.Text = lblDisplay.Text & num & ControlChars.NewLine

Display Numbers (Cont.) num = x * x lblDisplay.Text = lblDisplay.Text & num & ControlChars.NewLine num = x * x lblDisplay.Text = lblDisplay.Text & num & ControlChars.NewLine num = x * x lblDisplay.Text = lblDisplay.Text & num & ControlChars.NewLine num = x * x lblDisplay.Text = lblDisplay.Text & num & ControlChars.NewLine num = x * x lblDisplay.Text = lblDisplay.Text & num & ControlChars.NewLine x = x + 1 x = 1

The For Loop For x As Integer = 1 To 5 num = x * x lblDisplay.Text = lblDisplay.Text & num & ControlChars.NewLine Next x x num