How to allow the program to know when to stop a loop.

Slides:



Advertisements
Similar presentations
Chapter 7 - Iteration. Chapter Goals Program repitiation statements – or loops – with the for, while, and do-while statements Program repitiation statements.
Advertisements

Tonight’s JavaScript Topics 1 Conditional Statements: if and switch The Array Object Looping Statements: for, while and do-while.
Conditional Statements and Loops. Today’s Learning Goals … Learn about conditional statements and their structure Learn about loops and their structure.
5-1 Flow of Control Recitation-01/25/2008  CS 180  Department of Computer Science  Purdue University.
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
Selection Statements choice of one among several blocks of code Java supports 3 kinds of selection statements: if statement – selects one block or leaves.
Tutorial 4 Decision Making with Control Structures and Statements Section A - Decision Making JavaScript Tutorial 4 -Decision Making with Control.
New Mexico Computer Science For All More Looping in NetLogo Maureen Psaila-Dombrowski.
Agenda Control Flow Statements Purpose test statement if / elif / else Statements for loops while vs. until statements case statement break vs. continue.
COMP 1001: Introduction to Computers for Arts and Social Sciences Programming in Scratch Monday, May 16, 2011.
THE BIG PICTURE. How does JavaScript interact with the browser?
Study Guide For Test Chapter 5, 6,& 7 Test is Friday, May 15th.
HOMEWORK REVIEW This is an if else statement layout if (condition) { code to be executed if condition is true; } else { code to be executed if condition.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
Institute for Personal Robots in Education (IPRE)‏ CSC 170 Computing: Science and Creativity.
CPS120 Introduction to Computer Science Iteration (Looping)
Mastery Objective: Students will understand how to use while loops in computer programming.
Control Structures By Shyam Gurram. Control Structure In this chapter we have two different types of structures. Conditional Structure Iterative Control.
ㅎㅎ logical operator if if else switch while do while for Third step for Learning C++ Programming Repetition Control Structures.
Saeed Ghanbartehrani Summer 2015 Lecture Notes #5: Programming Structures IE 212: Computational Methods for Industrial Engineering.
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.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements I.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Review, Pseudocode, Flow Charting, and Storyboarding.
CSCI-100 Introduction to Computing
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
CPS120 Introduction to Computer Science Iteration (Looping)
While and If-Else Loops ROBOTC Software. While Loops While loop is a structure within ROBOTC Allows a section of code to be repeated as long as a certain.
Working with Loops, Conditional Statements, and Arrays.
Intro to Loops 1.General Knowledge 2.Two Types of Loops 3.The WHILE loop 1.
Program Structures Chapter 5. 5 Branching Allows different code to execute based on a conditional test. if, if-else, and switch statements.
XP Tutorial 3 New Perspectives on JavaScript, Comprehensive1 Working with Arrays, Loops, and Conditional Statements Creating a Monthly Calendar.
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana (say Doc-tor Way-oo-see-jah-nah, Doc-tor, or Bah-bah)
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
JavaScript JavaScript ( Condition and Loops ). Conditional Statements If Statement If...else Statement if (condition) { code to be executed if condition.
5a – While Loops Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
Learning Javascript From Mr Saem
Discussion 4 eecs 183 Hannah Westra.
August 31 Intro to CS.
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
Repetition Structures Chapter 9
JavaScript Loops.
Scratch: iteration / repetition / loops
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.
Chapter 5 Decisions. Chapter 5 Decisions ssential uestion: How are Boolean expressions or operators used in everyday life?
Web Programming– UFCFB Lecture 16
Agenda Control Flow Statements Purpose test statement
LESSON 11 – WHILE LOOPS UNIT 5 – 1/10/17.
Looping and Repetition
CPS120: Introduction to Computer Science
Welcome to <INSERT school name>’s
Scratch: selection / branching/ if / If…else / compound conditionals / error trapping by Mr. Clausen.
Iteration: Beyond the Basic PERFORM
Iteration: Beyond the Basic PERFORM
Algorithms Take a look at the worksheet. What do we already know, and what will we have to learn in this term?
Programs as Directions
Intro to Programming CURIE 2011.
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
ICT Programming Lesson 3:
Welcome to Mountain View Elementary School!
There many situations comes in real life when we need to make some decisions and based on these decisions, we decide what should we do next. Similar situations.
Introduction to Computer Science
Python While Loops.
Millennium High School Agenda Calendar
Millennium High School Agenda Calendar
GCSE Computing:: While Loops
Selections and Loops By Sarah, Melody, Teresa.
If-Statements and If/Else Statements
G6DICP - Lecture 5 Control Structures.
Presentation transcript:

How to allow the program to know when to stop a loop. While Loops How to allow the program to know when to stop a loop.

REVIEW! Why do we use if statements in JavaScript? To break out of some block of code To do something only if a condition is true To do something while a condition is true To repeat something for a fixed number of times

REVIEW! Why do we use if/else statements in JavaScript? To repeat something for a fixed number of times To either do something if a condition is true or do something else To break out of some block of code To repeat something while a condition is true

When would we use a While loop instead of a For Loop???? While Loops vs For Loop When would we use a While loop instead of a For Loop????

While Loop vs For Loop For loops are forcing the computer to loop a certain set of code a specific set of times. It is possible that code can run into an error if that number is too small or too large. A while loop doesn’t place an exact number necessarily, rather has a procedure repeat until something interrupts it. While loops are similar to If statements because they repeat until a certain condition is met.