Algorithms Take a look at the worksheet. What do we already know, and what will we have to learn in this term?

Slides:



Advertisements
Similar presentations
Switch code for Lab 4.2 switch (input) { /* input is a variable that we will test. */ case 'M': printf("The prefix is equal to 1E6.\n"); break; case 'k':
Advertisements

How SAS implements structured programming constructs
CS 4 Intro to Programming using Visual Basic Do Loops Patchrawat Uthaisombut University of Pittsburgh 1 based on lecture notes by D. Schneider.
CS107 Introduction to Computer Science Lecture 3, 4 An Introduction to Algorithms: Loops.
ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 4 Client Side Scripting JavaScript Looping.
CS0004: Introduction to Programming Repetition – Do Loops.
Creating Computer Programs lesson 27. This lesson includes the following sections: What is a Computer Program? How Programs Solve Problems Two Approaches:
Loops (Part 1) Computer Science Erwin High School Fall 2014.
Scripts and Flow Control. Scripts So far we have been entering commands directly into the command line But there is a better way Script files (and functions)
Executes a statement or statements for a number of times – iteration. Syntax for(initialize; test; increment) { // statements to be executed } Initial.
True BASIC Ch. 6 Practice Questions. What is the output? PRINT X LET X = -1 PRINT X FOR X = 4 TO 5 STEP 2 PRINT X NEXT X PRINT X END.
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
Fundamentals of Software Development ISlide 1 Recap: Key ideas in WordGames ClassClass –versus instances –Defining –use of fields –Constructors E.g., to.
Lecture 12 Another loop for repetition The while loop construct © 2007 Daniel Valentine. All rights reserved. Published by Elsevier.
New Mexico Computer Science For All More Looping in NetLogo Maureen Psaila-Dombrowski.
Simple Python Loops Sec 9-7 Web Design.
For Loops. Challenge: Racer ● Simulate a race that says “Now on lap X” for 10 laps. ● Make X vary, so it says 1, then 2, then 3 ● Use only one output.
Programming with App Inventor Computing Institute for K-12 Teachers Summer 2012 Workshop.
Bug Session Four. Session description Objectives Session activities summary Resources Prior knowledge of sequencing instructions using Bug Bug website.
Fundamentals of Software Development 1Slide 1 Loops A loop is:A loop is: –a block of code that executes repeatedly while some condition holds true. Java.
Lecture 4: Calculating by Iterating. The while Repetition Statement Repetition structure Programmer specifies an action to be repeated while some condition.
1 CSCI N201 Programming Concepts and Database 9 – Loops Lingma Acheson Department of Computer and Information Science, IUPUI.
Chapter 9 Macros And Visual Basic For Applications.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
For Code Next For Code Next A loop is a segment of a code that repeats (changing slightly each time)
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
Agenda Perform Quiz #1 (20 minutes) Loops –Introduction / Purpose –while loops Structure / Examples involving a while loop –do/while loops Structure /
Fundamentals of Software Development 1Slide 1 Loops A loop is:A loop is: –a block of code that executes repeatedly while some condition holds true. Java.
Language Find the latest version of this document at
Program Structures Chapter 5. 5 Branching Allows different code to execute based on a conditional test. if, if-else, and switch statements.
1 Overview of Programming Principles of Computers.
CODING VOCABULARY.  Binary  A number system based on 2  Hexadecimal  A number system based on 16  Domain  An internet location registered with the.
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.
Computer Program Flow Control structures determine the order of instruction execution: 1. sequential, where instructions are executed in order 2. conditional,
PYTHON WHILE LOOPS. What you know While something is true, repeat your action(s) Example: While you are not facing a wall, walk forward While you are.
Learning Javascript From Mr Saem
PROGRAMMING USING PYTHON LANGUAGE ASSIGNMENT 1. INSTALLATION OF RASPBERRY NOOB First prepare the SD card provided in the kit by loading an Operating System.
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.
Control Structure  What is control Structure?  Types of Controls  Use the control structure in VBScript.  Example Summery.
Chapter 6 Controlling Program Flow with Looping Structures.
CPSC 233 Tutorial January 21 st /22 nd, Linux Commands.
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.
Loops A loop is: Java provides three forms for explicit loops:
Web Design II Flat Rock Community Schools
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
JavaScript Loops.
Transition to Code Upsorn Praphamontripong CS 1110
Think What will be the output?
Ch 7: JavaScript Control Statements I.
Iterations Programming Condition Controlled Loops (WHILE Loop)
LESSON 11 – WHILE LOOPS UNIT 5 – 1/10/17.
For Loops October 12, 2017.
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Looping and Repetition
When I want to execute the subroutine I just give the command Write()
Scratch: selection / branching/ if / If…else / compound conditionals / error trapping by Mr. Clausen.
Patterns to KNOW.
Topics: Programming Constructs: loops & conditionals Digital Input
Visual Basic – Decision Statements
Computer Science Core Concepts
Creating Computer Programs
A LESSON IN LOOPING What is a loop?
Program Flow.
PROGRAM FLOWCHART Iteration Statements.
Python While Loops.
Creating Computer Programs
How to allow the program to know when to stop a loop.
Week 3 – Repetition (ctd.)
Presentation transcript:

Algorithms Take a look at the worksheet. What do we already know, and what will we have to learn in this term?

Loops If you need to repeat a sequence of commands a certain number of times, you should use loops.

For Loops A for loop repeats a command a certain number of times, i.e. runs the command for a certain set of inputs. for (statement 1; statement 2; statement 3) {     code block to be executed } Statement 1 is executed before the loop (the code block) starts. Statement 2 defines the condition for running the loop (the code block). Statement 3 is executed each time after the loop (the code block) has been executed.

For Loops, Example for (i = 0; i < 5; i++) { text += "The number is " + i + "<br>"; } From the example above, you can read: Statement 1 sets a variable before the loop starts (var i = 0). Statement 2 defines the condition for the loop to run (i must be less than 5). Statement 3 increases a value (i++) each time the code block in the loop has been executed.

While Loops A while loop repeats a command, while a certain criteria holds true. while (condition) { code block to be executed } Example: while (i < 10) { text += "The number is " + i; i++; }