NQC: Control Structures: Loops Last updated 10/5/05 References: NQC Tutorial Baum Chapter 3 Baum Appendix D pg 368.

Slides:



Advertisements
Similar presentations
Java Control Statements
Advertisements

While loops.
How SAS implements structured programming constructs
Chapter 13 Control Structures. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display Control Structures Conditional.
The "if structure" is used to execute statement(s) only if the given condition is satisfied.
1 Chapter Five Selection and Repetition. 2 Objectives How to make decisions using the if statement How to make decisions using the if-else statement How.
Lesson 5 - Decision Structure By: Dan Lunney
Loops (Part 1) Computer Science Erwin High School Fall 2014.
Visual Basic.NET BASICS Lesson 10 Do Loops. 2 Objectives Explain what a loop is. Use the Do While and Do Until loops. Use the InputBox function. Use the.
Global Variables When we introduced variables we defined them inside task main() task main() { int x; statement; …. } The variable x is only defined inside.
Control Structures 2 Chapter 6. © Janice Regan 2003 Basic Loops  When one action is to be repeated a number of times a loop is used. Loops are repetition.
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.
NQC: Control Structures: Branching Last updated 10/6/05 10:00am References: Baum Chapter 3 pp NQC Tutorial pp Baum Appendix D pg 368.
Do Loops A Do..Loop terminates based on a condition that is specified Execution of a Do..Loop continues while a condition is True or until a condition.
NQC: Not Quite C (last updated 9/14/05 2:24pm) Each NQC program has a task main () The program is contained within curly braces { ….. } task main() { SetSensor(SENSOR_1,
Chapter 61 Post Test Loop Do statement(s) Loop Until condition Loop is executed once and then the condition is tested. If it is False, the loop is run.
New Mexico Computer Science For All More Looping in NetLogo Maureen Psaila-Dombrowski.
UNIT II Decision Making And Branching Decision Making And Looping
Fac of Ene & Surveying U.S.Q.1 E0001 Computers in Engineering DO.... LOOP.
Events Chapter 7 Part 2. While a Key is Pressed Event Specialized event An event occurs when you press a key and continues until you take your finger.
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
Q and A for Chapter 7 Students of CS104, and me, your benevolent professor, Victor T. Norman, PhD.
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.
ㅎㅎ logical operator if if else switch while do while for Third step for Learning C++ Programming Repetition Control Structures.
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,
Control Structures II Repetition (Loops). Why Is Repetition Needed? How can you solve the following problem: What is the sum of all the numbers from 1.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Chapter 4 Control Structures: Part I 1 3 “ There is No goto in Java ” Structured programming: the building blocks There are 3 different kinds.
Loops For, While, and Do While. Loop structure Loops need a control variable to operate correctly. This variable must be declared, initialized, updated,
ITERATIVE STATEMENTS. Definition Iterative statements (loops) allow a set of instruction to be executed or performed several until condition are met.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
1 A Balanced Introduction to Computer Science, 2/E David Reed, Creighton University ©2008 Pearson Prentice Hall ISBN Chapter 13 Conditional.
Conditional Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Starting Out With Java 5 Control Structures to Objects By Tony Gaddis Copyright © 2005, Pearson Addison-Wesley. All rights reserved. Chapter 4 Slide #1.
Structured Programming The Basics. Control structures They control the order of execution What order statements will be done in, or whether they will.
Think Possibility 1 Iterative Constructs ITERATION / LOOPS C provides three loop structures: the for-loop, the while-loop, and the do-while-loop. Each.
1 For Loops l From Chapter 9 l A shorthand way of coding count loops.
February 25,  The BDE(Begin-During-End) event.  Worksheet – Exercise # 9 Instructions  2nd Period Test.
Chapter 7: Repetition Structure (Loop) Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills.
USING CONDITIONAL CODE AMIR KHANZADA. Conditional Statement  Conditional statements are the set of commands used to perform different actions based on.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Chad’s C++ Tutorial Demo Outline. 1. What is C++? C++ is an object-oriented programming (OOP) language that is viewed by many as the best language for.
5a – While Loops Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
Learning Javascript From Mr Saem
Chapter 5: Looping. Using the while Loop Loop – A structure that allows repeated execution of a block of statements Loop body – A block of statements.
Chapter 6 Controlling Program Flow with Looping Structures.
Chapter 7 Control Structures. Java has very flexible three looping mechanisms. You can use one of the following three loops:  while Loop  do...while.
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.
Topic : While, For, Do-While Loop Guided By : Branch : Batch :
Introducing Do While & Do Until Loops & Repetition Statements
Loop Control Structure.
Looping and Repetition
Loops October 10, 2017.
Iteration with While You can say that again.
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?
Module 4 Loops.
Repetition Control Structure
Control structures to direct program flow
Three Special Structures – Case, Do While, and Do Until
Visual Basic – Decision Statements
ICT Programming Lesson 3:
A LESSON IN LOOPING What is a loop?
Relational Operators.
FLUENCY WITH INFORMATION TECNOLOGY
PROGRAM FLOWCHART Iteration Statements.
CS2011 Introduction to Programming I Loop Statements (I)
Chapter 13 Conditional Repetition
Chapter 2 Sets Active Learning Lecture Slides
Looping Structures.
Presentation transcript:

NQC: Control Structures: Loops Last updated 10/5/05 References: NQC Tutorial Baum Chapter 3 Baum Appendix D pg 368.

While Control Structure Sample forms 1)while(Timer(0) <= 10) x+=5; 2)while(z != 5) { if(SENSOR_1==0) { STATEMENTS EXECTUED IF TRUE } else { STATEMENTS EXECTUED IF FALSE } General Form while(condition) statement General Form while(condition) statement

Creating an Infinite Loop while(true) { until(Timer(0) > TIMER_LIMIT); PlayTone(440, 10); ClearTimer(0); bumps = 0; }

A Closely Related Cousin to the while do { Toggle(OUT_A); Off(Out_B); } while (SENSOR_2 <= 10) Notice the do while is always executed at least one time since the test of the condition is at the bottom of the loop. General Form do statement while(condition) General Form do statement while(condition)

The until control structure Example until(SENSOR_2>=5) x+=1; This is often used to trigger a segment of code when an event occurs until(SENSOR_1==1); Note in the last example the statement is the null statement. The program acts as though it holds at this point until the event SENSOR_1==1 occurs and then it is realeased to the next statement in the program. General Form until(condition) statement General Form until(condition) statement