More Loops.

Slides:



Advertisements
Similar presentations
Loops –Do while Do While Reading for this Lecture, L&L, 5.7.
Advertisements

Looping while … do …. Condition Process 2 Process 1 Y Repeated Loop.
ABNIAC The following slide presentation is to acquaint the student with ABNIAC. The version used for presentation is the Java version, which can be found.
CS0004: Introduction to Programming Repetition – Do Loops.
CSE 1301 Lecture 6B More Repetition Figures from Lewis, “C# Software Solutions”, Addison Wesley Briana B. Morrison.
Additional control structures. The if-else statement The if-else statement chooses which of two statements to execute The if-else statement has the form:
1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
1 10/20/08CS150 Introduction to Computer Science 1 do/while and Nested Loops Section 5.5 & 5.11.
CMPUT 101 Lab #6 October 29, :00 – 17:00. Array in C/C++ Array is a structure type variable. One dimension of array int: int num[3]; There are.
Whole Number Bingo. What is a whole number? A whole number is a number that does not contain fractions. A whole number is a number that does not contain.
1 Lab Session-III CSIT-120 Spring 2001 Revising Previous session Data input and output While loop Exercise Limits and Bounds GOTO SLIDE 13 Lab session.
The Answer is RIGHT.
Addition and Subtraction of Integers
1 Lab Session-III CSIT-120 Fall 2000 Revising Previous session Data input and output While loop Exercise Limits and Bounds Session III-B (starts on slide.
 What are the different types of loops? ◦ Do….While  Performs statements within loop while a condition is true ◦ Do….Until  Performs statements within.
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.
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.
Lec 4: while loop and do-while loop. Review from last week if Statements if (num < 0.5){...println("heads"); } if –else Statements if (num < 0.5){...println("heads");
More on Logic Today we look at the for loop and then put all of this together to look at some more complex forms of logic that a program will need The.
Repetition Structures Repetition Structures allow you to write programs that will repeat program steps multiple times. –Also called Loops –Counter controlled.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 5 Looping.
Loops and Simple Functions CS303E: Elements of Computers and Programming.
Agenda Perform Quiz #1 (20 minutes) Loops –Introduction / Purpose –while loops Structure / Examples involving a while loop –do/while loops Structure /
Chapter 6 Looping Structures. Do…LoopDo…Loop Statement Can operate statements repetitively Do intx=intx + 1 Loop While intx < 10 –The Loop While operates.
Special Methods in Java. Mathematical methods The Math library is extensive, has many methods that you can call to aid you in your programming. Math.pow(double.
1 Project 7: Looping. Project 7 For this project you will produce two Java programs. The requirements for each program will be described separately on.
More on Logic Today we look at the for loop and then put all of this together to look at some more complex forms of logic that a program will need The.
Learning about Inverse Operations. What is the inverse of Opening the door? Turning Right? Driving Forward? The inverse undoes the original function.
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.
Nested For Loops. First, the rules to these loops do not change. We are sticking one loop inside another. while(condition) { // loop body } do { // loop.
CPSC 233 Tutorial 5 February 2 th /3 th, Java Loop Statements A portion of a program that repeats a statement or a group of statements is called.
General Condition Loop A general condition loop just loops while some condition remains true. Note that the body of the loop should (eventually) change.
Learning Javascript From Mr Saem
1.5 Adding Integers. Adding Integers! When adding two positive numbers, Start at 5 Move to the right 7 spaces Answer : 12.
26/06/ Iteration Loops For … To … Next. 226/06/2016 Learning Objectives Define a program loop. State when a loop will end. State when the For.
Loops Review. How to generate random numbers Math.random() will return a random decimal value in the form of a double. double num1 = Math.random(); num1.
Topic : While, For, Do-While Loop Guided By : Branch : Batch :
CS 106A, Lecture 4 Introduction to Java
Introduction to Computing Science and Programming I
while Repetition Structure
Tutorial 10 – Class Average Application Introducing the Do…Loop While and Do…Loop Until Repetition Statements Outline Test-Driving the Class Average.
Subtracting Mixed Numbers
Programming Fundamentals
Lecture 07 More Repetition Richard Gesick.
Lecture 4B More Repetition Richard Gesick
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.
Please use speaker notes for additional information!
Alternate Version of STARTING OUT WITH C++ 4th Edition
More Loops.
Chapter 8 The Loops By: Mr. Baha Hanene.
For Loops.
Module 4 Loops.
Lec 4: while loop and do-while loop
3.1 Iteration Loops For … To … Next 18/01/2019.
Computing Fundamentals
Python programming exercise
CS100J Lecture 3 Previous Lecture This Lecture Programming Concepts
Let’s all Repeat Together
Relations.
A LESSON IN LOOPING What is a loop?
Java Programming Loops
Chapter 4: Repetition Structures: Looping
Developing a Program.
Basic Lessons 5 & 6 Mr. Kalmes.
Little Man Computer (continued).
Control Structures.
Learning Intention I will learn about the standard algorithm for input validation.
This is an introduction to JavaScript using the examples found at the CIS17 website. In previous examples I specified language = Javascript, instead of.
Programming Fundamental
Presentation transcript:

More Loops

While loops review while(condition(s)) { // body of the loop } Loop will execute until the condition is false

Do While loop do { // body of the loop } while(condition(s)) Exact same as while loop except the difference is that the loop condition is tested at the end. That means the body of the loop is run at least once.

Use a do while loop to display every number between 0-100, put a space between each one, no end line.

Using a do while loop, output every character from ‘a’ to ‘z’ Using a do while loop, output every character from ‘a’ to ‘z’. Put a space between each one and no line feeds.

Declare an integer num1 = 1000 Declare an integer num1 = 1000. Use a do while loop to keep asking for a number between 0-100. Every time a number is entered, take that number and subtract it from num. Keep going until the value of num1 is less than 0.

Ask the user for three integer inputs and keep adding them together until you hit a number that can be evenly divided by 10. Each loop will add to the value of the previous loop. Let us know how many times you had to do the loop until you hit that number and what that number is.