1 MATERI PENDUKUNG JUMP Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0.

Slides:



Advertisements
Similar presentations
Loops (Part 1) Computer Science Erwin High School Fall 2014.
Advertisements

1 MATERI PENDUKUNG CLASS ABSTRACT Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0.
1 Lecture 11:Control Structures II (Repetition) (cont.) Introduction to Computer Science Spring 2006.
COMP 14 Introduction to Programming Miguel A. Otaduy May 21, 2004.
Iteration This week we will learn how to use iteration in C++ Iteration is the repetition of a statement or block of statements in a program. C++ has three.
CS 106 Introduction to Computer Science I 02 / 12 / 2007 Instructor: Michael Eckmann.
Introduction to Computers and Programming Lecture 10: For Loops Professor: Evan Korth New York University.
Switch structure Switch structure selects one from several alternatives depending on the value of the controlling expression. The controlling expression.
Chapter 5: Control Structures II (Repetition)
Repetition Statements repeat block of code until a condition is satisfied also called loops Java supports 3 kinds of loops: while statement – repeats a.
1 Chapter 3 Flow of Control. 2 Outline  How to specify conditions?  Relational, Equality and Logical Operators  Statements  Statements: compound statement.
Loop Statements (Iteration). Iteration  A portion of a program that repeats a statement or group of statements is called a loop.  Each repetition of.
1 MATERI PENDUKUNG METHOD OVERRIDING Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0.
1 Loops Loops repeat (iterate) a block of statements for a number of times. A terminating condition tells a loop when to stop iterating (e.g. terminate.
1 MATERI PENDUKUNG METHOD Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0.
1 CS 192 Lecture 9 Winter 2003 December 19, 2003 Dr. Shafay Shamail.
Chapter 2 Control. "The Practice of Computing Using Python", Punch & Enbody, Copyright © 2013 Pearson Education, Inc. Repetition, quick overview.
Control Structures Session 03 Mata kuliah: M0874 – Programming II Tahun: 2010.
1 4.8The do/while Repetition Structure The do/while repetition structure –Similar to the while structure –Condition for repetition tested after the body.
Lecture 8: Choosing the Correct Loop. do … while Repetition Statement Similar to the while statement Condition for repetition only tested after the body.
Chapter 7 Additional Control Structures. 2 2 void GetYesOrNo (/* out */ char& response) // Inputs a character from the user // Postcondition: response.
Chapter 5 Loops. Overview u Loop Statement Syntax  Loop Statement Structure: while, for, do-while u Count-Controlled Loops u Nested Loops u Loop Testing.
1. Agenda for loop Short-handed notation How to use break and continue 2.
1 Conditionals In many cases we want our program to make a decision about whether a piece of code should be executed or not, based on the truth of a condition.
Program Flow Control - Looping Addis Ababa Institute of Technology Yared Semu April 2012.
L OO P S While writing a program, there may be a situation when you need to perform some action over and over again. In such situation you would need.
Chapter 05 (Part III) Control Statements: Part II.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 ‏ Control Structures.
Overview of Java Loops By: Reid Hunter. What Is A Loop? A loop is a series of commands that will continue to repeat over and over again until a condition.
Sahar Mosleh California State University San MarcosPage 1 Program Control Statement.
J AVA P ROGRAMMING 2 C H 03: C ONTROL STATEMENTS if, for loop (review) switch, while, do while break, continue Fall Java Programming.
ITERATIVE STATEMENTS. Definition Iterative statements (loops) allow a set of instruction to be executed or performed several until condition are met.
Loops & List Intro2CS – week 3 1. Loops -- Motivation Sometimes we want to repeat a certain set of instructions more than once. The number of repetitions.
REPETITION STATEMENTS - Part2 Structuring Input Loops Counter-Controlled Repetition Structure Sentinel-Controlled Repetition Structure eof()-Controlled.
CS 161 Introduction to Programming and Problem Solving Chapter 18 Control Flow Through C++ Program Herbert G. Mayer, PSU Status 10/8/2014 Initial content.
Think Possibility 1 Iterative Constructs ITERATION / LOOPS C provides three loop structures: the for-loop, the while-loop, and the do-while-loop. Each.
CMSC 1041 More Loops ‘for’ loops and ‘do-while’ loops.
BY ILTAF MEHDI (MCS, MCSE, CCNA)1. INSTRUCTOR: ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) BY ILTAF MEHDI (MCS, MCSE, CCNA)2 Chapter No: 04 “Loops”
ECE122 Feb 10, Unary Operator An operator that takes only a single operand Plus: + Minus: – Cast: (type). E.g. (double)
Conditional Statements A conditional statement lets us choose which statement will be executed next Conditional statements give us the power to make basic.
Infinite for Loop If you omit the test condition, the value is assumed to be TRUE so the loop will continue indefinitely unless you provide some other.
Follow up from lab See Magic8Ball.java Issues that you ran into.
CONTROL STATEMENTS if-then, if-then-else, switch/case For, While, Do-while, goto Break, continue.
REPETITION CONTROL STRUCTURE
Unit-1 Introduction to Java
Warm-up Program Use the same method as your first fortune cookie project and write a program that reads in a string from the user and, at random, will.
The Linux Command Line Chapter 29
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Looping and Repetition
Programming Fundamentals Lecture #6 Program Control
Structured Program Development in C
for, do-while and switch statments
LOOPS BY: LAUREN & ROMEO.
CSC215 Lecture Flow Control.
Lab5 PROGRAMMING 1 Loop chapter4.
© 2016 Pearson Education, Ltd. All rights reserved.
Loops.
By Hector M Lugo-Cordero September 3, 2008
A LESSON IN LOOPING What is a loop?
ECE 103 Engineering Programming Chapter 20 Change in Flow of Control
Seating “chart” Front - Screen rows Back DOOR.
CS149D Elements of Computer Science
More Loops Topics Counter-Controlled (Definite) Repetition
More Loops Topics Counter-Controlled (Definite) Repetition
Department of Computer Science
CSC215 Lecture Control Flow.
How to allow the program to know when to stop a loop.
Programming Fundamental
break & continue Statements
Introduction to Python
Presentation transcript:

1 MATERI PENDUKUNG JUMP Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0

2 The break statement The break statement will allow you to exit a loop structure before the test condition is met. Once a break statement is encountered, the loop immediately terminates, skipping any remaining code. For instance: int x = 0;

3 while (x < 10){ System.out.println("Looping"); x++; if (x == 5) break; else... //do something else } In this example, the loop will stop executing when x equals 5.

4 The continue statement The continue statement is used to skip the rest of the loop and resume execution at the next loop iteration. for ( int x = 0 ; x < 10 ; x++){ if(x == 5) continue; //go back to beginning of loop with x=6 System.out.println("Looping"); } This example will not print "Looping" if x is 5, but will continue to print for 6, 7, 8, and 9.