1 Pertemuan 06 Repetition Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:

Slides:



Advertisements
Similar presentations
While loops.
Advertisements

Pertemuan 13 Threads Matakuliah: H0483 / Network Programming Tahun: 2005 Versi: 1.0.
1 Pertemuan 04 Proxy/Cache Matakuliah: H0491/Praktikum Jaringan Komputer Tahun: 2005 Versi: 1/0.
1 Pertemuan 22 Radix Sort Matakuliah: T0016/Algoritma dan Pemrograman Tahun: 2005 Versi: versi 2.
1 Pertemuan 6 Elementary UDP Sockets Matakuliah: H0483 / Network Programming Tahun: 2005 Versi: 1.0.
Dynamic SQL Pertemuan 11 Matakuliah: T0413/Current Popular IT II Tahun: 2007.
12 - Organisation Matakuliah: G0622/Bahasa Inggris 1 Tahun: 2005 Versi: 1.01.
Session 5 JavaScript/JScript: Control Structures II Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5.
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.
Executes a statement or statements for a number of times – iteration. Syntax for(initialize; test; increment) { // statements to be executed } Initial.
1 Pertemuan 10 Arsitektur Jaringan Model OSI Matakuliah: H0174/Jaringan Komputer Tahun: 2006 Versi: 1/0.
1 Pertemuan 26 Object Relational Database Management System (Lanjutan) Matakuliah: M0174/OBJECT ORIENTED DATABASE Tahun: 2005 Versi: 1/0.
1 Pertemuan 23 Object database design (Lanjutan bagian 2) Matakuliah: M0174/OBJECT ORIENTED DATABASE Tahun: 2005 Versi: 1/0.
1 Pertemuan 13 BACK PROPAGATION Matakuliah: H0434/Jaringan Syaraf Tiruan Tahun: 2005 Versi: 1.
1 Parts of a Loop (reminder) Every loop will always contain three main elements: –Priming: initialize your variables. –Testing: test against some known.
1 Pertemuan 14 Object Query Language (Lanjutan bagian 1) Matakuliah: M0174/OBJECT ORIENTED DATABASE Tahun: 2005 Versi: 1/0.
1 Pertemuan 04 Expression Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
07 - Advertising Matakuliah: G0622/Bahasa Inggris 1 Tahun: 2005 Versi: 1.01.
1 Pertemuan 21 Parallelism and Superscalar Matakuliah: H0344/Organisasi dan Arsitektur Komputer Tahun: 2005 Versi: 1/1.
1 Pertemuan 07 Procedures Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
1 Pertemuan 21 Audit Reporting Matakuliah:A0274/Pengelolaan Fungsi Audit Sistem Informasi Tahun: 2005 Versi: 1/1.
1 Pertemuan 05 Selection Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
1 Pertemuan 11 QUIZ Matakuliah: J0274/Akuntansi Manajemen Tahun: 2005 Versi: 01/00.
11 - Innovation Matakuliah: G0622/Bahasa Inggris 1 Tahun: 2005 Versi: 1.01.
1 Pertemuan 20 Time & Condition Clauses with Future reference Matakuliah: G0134 – Grammar III Tahun: 2005 Versi: revisi 1.
1 Pertemuan 18 I wish, If only Matakuliah: G0134 – Grammar III Tahun: 2005 Versi: revisi 1.
1 Pertemuan 9 The Manipulative part of the object data model Matakuliah: M0174/OBJECT ORIENTED DATABASE Tahun: 2005 Versi: 1/0.
1 Pertemuan #3 Clocks and Realtime Matakuliah: H0232/Sistem Waktu Nyata Tahun: 2005 Versi: 1/5.
Week 11 Recap CSE 115 Spring Want to write a programming language? You’ll need three things: You’ll need three things: –Sequencing –Selection Polymorphism.
1 Pertemuan 9 JARINGAN LEARNING VECTOR QUANTIZATION Matakuliah: H0434/Jaringan Syaraf Tiruan Tahun: 2005 Versi: 1.
Loops Repetition Statements. Repetition statements allow us to execute a statement multiple times Often they are referred to as loops Like conditional.
1 Pertemuan 03 Representing Data Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
© 2004 Pearson Addison-Wesley. All rights reserved5-1 Iterations/ Loops The while Statement Other Repetition Statements.
1 Pertemuan 10 The Manipulative part of the object data model (Lanjutan bagian 1) Matakuliah: M0174/OBJECT ORIENTED DATABASE Tahun: 2005 Versi: 1/0.
1 Pertemuan 8 The Object Definition Language (Lanjutan) Matakuliah: M0174/OBJECT ORIENTED DATABASE Tahun: 2005 Versi: 1/0.
Lecture Set 5 Control Structures Part D - Repetition with Loops.
CPS120 Introduction to Computer Science Iteration (Looping)
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 2) UTPA – Fall 2011 Part of the slides is from Dr. John Abraham’s previous.
Repetition Statements.  Often it is necessary to repeat statements many times  Java has two ways of doing this  while statements  for statements.
1 INF110 Visual Basic Programming AUBG Spring semester 2011 Reference books: Schneider D., An Introduction to Programming Using Visual Basic, Prentice.
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.
C++ for Engineers and Scientists, Third Edition1 Objectives In this chapter, you will learn about: Basic loop structures while loops Interactive while.
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,
Saeed Ghanbartehrani Summer 2015 Lecture Notes #5: Programming Structures IE 212: Computational Methods for Industrial Engineering.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 ‏ Control Structures.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
CPS120 Introduction to Computer Science Iteration (Looping)
Repetition Control Structure. Introduction Many applications require certain operations to be carried out more than once. Such situations require repetition.
For…Next Loops, Checked List Boxes, and Combo Boxes Chapter 5.
Input Boxes, List Boxes, and Loops Chapter 5. 2 Input Boxes Method for getting user’s attention to obtain input. InputBox() for obtaining input MessageBox()
Chapter 7: Repetition Structure (Loop) Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills.
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 2B) UTPA – Fall 2011 Part of the slides is from Dr. John Abraham’s previous.
Dani Vainstein1 VBScript Session 5. Dani Vainstein2 What we learn last session? Branching Branching using If … Then … Else statement. Branching using.
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.
Matakuliah : D0524 / Algoritma dan Pemrograman Komputer
Pertemuan 04 Proxy/Cache
Chapter 4 Repetition Statements (loops)
Pertemuan 20 Building Object Database Application (Lanjutan bagian 3)
Pertemuan 22 The Business Views of the Technology Architecture
Problem Solving and Control Statements: Part 2
Control Structures: Part 2
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 2B) UTPA – Fall 2011 Part of the slides is from Dr. John Abraham’s previous.
4. Functions and Control Statements
Control Structures: Part 1
Outline Altering flow of control Boolean expressions
3.5- The while Statement The while statement has the following syntax:
Problem Solving and Control Statements
Case & Repetitive Statements
PROGRAM FLOWCHART Iteration Statements.
Presentation transcript:

1 Pertemuan 06 Repetition Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:

2 Learning Outcomes Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu : Mendemonstrasikan penggunaan perintah pengulangan

3 Outline Materi The Do … Loop Structure The For…Next Loop Structure Nested Loops

4 The Do … Loop Structure Syntax and Action of the Do…Loop Do statementblock Loop Run Time: The Effect of the Do…Loop Structure –Statements in a loop’s interior are executed one at a time. –The Do marks the top of the loop. –The Loop sends the execution back to the top.

5 The Do … Loop Structure Do While…Loop Do While condition statementblock Loop Run Time: The Effect of the Do While…Loop Structure –Loop continues to execute “while the condition is true.” –Loop is exited when the condition is false.

6 The Do … Loop Structure Coding the Loop Body –One or more statements in the loop body must eventually cause the condition to become false. –Order of statements inside loop affects the result of the loop. –Loop may terminate immediately. –Loop can be viewed as a meta statement.

7 The Do … Loop Structure Do Loop…While –Works like the Do While…Loop. –Termination at the bottom of the loop. –Syntax: Do statementblock Loop While condition

8 The Do … Loop Structure Do Until…Loop and Do…Loop Until –Do Until…Loop Termination condition at the top of the loop. Same syntax and action as the Do While…Loop. –Except: »Difference in keywords. »Loop statements inside the Do Until…Loop are executed when the conditions are False. –Do…Loop Until Termination condition at the bottom of the loop. Exit when the condition is True. Initialization and Termination Loops may start or end at the wrong place. –The initialization statement may be off. –The condition operator may need to be changed. –The order of statements within the loop may need to be changed.

9 The For…Next Loop Structure Syntax and Action of For…Next For counter = start To end statementblock Next –Run Time: The Effect of the For…Next Structure Counter variable and start and end expressions must be evaluated to control the number of times the loop will be processed. For…Next versus Do…Loop Variations –Use a For…Next loop when the number of loop iterations can be determined. –Use a Do…Loop variety only when the number of iterations depends on the results of statements inside the loop.

10 The For…Next Loop Structure The Step Amount –Counter variable may be incremented by a step amount, such 3 instead of 1. –Syntax: For counter = start To end Step increment statementblock Next Avoiding For…Next Errors –Do not place statements inside the loop that change start, end, and increment expressions. –Do not change the counter variable inside the loop.

11 Nested Loops Loops may be embedded inside of other loops. Nested Do While…Loops Do While condition1 statementblock1a Do While condition2 statementblock2 Loop statementblock1b Loop Nested For…Next Loops For counter1 = start1 To end1 statementblock1a For counter2 = start2 To end2 statementblock2 Next statementblock1b Next