Laptop Instrument Meeting 7 February 7, 2018.

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

Control Structure There are two kind of control structure in GWBASIC one is iteration/loop or repetitive and second make decision/condition. Iteration/Loop.
CS107 Introduction to Computer Science Lecture 3, 4 An Introduction to Algorithms: Loops.
Object Oriented Programming A programming concept which views programs as objects with properties and ways to manipulate the object and the properties.
1 PHP Statement Constructs Server Scripting. 5-2 Basic Statement All Statements end in a semicolon. Statements are delimited from the HTML code by enclosing.
Loops (Part 1) Computer Science Erwin High School Fall 2014.
Creating a Histogram using the Histogram Function.
Basic Control Structures Control order of execution of statements sequential selection iteration - Repeat some action while a certain condition is true.
PHP Functions and Control Structures. 2 Defining Functions Functions are groups of statements that you can execute as a single unit Function definitions.
Computer Science 1620 Loops.
CS107 Introduction to Computer Science Loops. Instructions Pseudocode Assign values to variables using basic arithmetic operations x = 3 y = x/10 z =
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.
A loop is a repetition control structure. it causes a single statement or block to be executed repeatedly What is a loop?
CS 106 Introduction to Computer Science I 02 / 12 / 2007 Instructor: Michael Eckmann.
Fall 2007ACS-1805 Ron McFadyen1 Ch 7 Loops Alice has two control structures for controlling the repeated execution of statements Loop While.
1 Lecture 14 Chapter 6 Looping Dale/Weems/Headington.
Repetition Structures: For Loop Constants CSC 1401: Introduction to Programming with Java Week 5 Wanda M. Kunkle.
1 Arithmetic in C. 2 Type Casting: STOPPED You can change the data type of the variable in an expression by: (data_Type) Variable_Name Ex: int a = 15;
© 2004 Pearson Addison-Wesley. All rights reserved5-1 Iterations/ Loops The while Statement Other Repetition Statements.
Copyright © Texas Education Agency, Computer Programming For Loops.
New Mexico Computer Science For All More Looping in NetLogo Maureen Psaila-Dombrowski.
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
Lecture 4 Introduction to Programming. if ( grade ==‘A’ ) cout
>>> # Fibonacci series:... # the sum of two elements defines the next... a, b = 0, 1 >>> while b < 10:... print b... a, b = b, a+b WHILE.
Lecture 4: Calculating by Iterating. The while Repetition Statement Repetition structure Programmer specifies an action to be repeated while some condition.
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.
ITERATIVE STATEMENTS. Definition Iterative statements (loops) allow a set of instruction to be executed or performed several until condition are met.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
Overview Go over parts of quiz? Another iteration structure for loop.
Topic: Control Statements. Recap of Sequence Control Structure Write a program that accepts the basic salary and allowance amount for an employee and.
Introduction to Computing Concepts Note Set 14. What if… You had to print “I love Java” to the screen 125 times. How? 125 lines of ▫ System.out.println(“I.
Chapter 6: Looping. Objectives Learn about the loop structure Create while loops Use shortcut arithmetic operators Create for loops Create do…while loops.
Why Repetition? Read 8 real numbers and compute their average REAL X1, X2, X3, X4, X5, X6, X7, X8 REAL SUM, AVG READ *, X1, X2, X3, X4, X5, X6, X7, X8.
Engineering Computing I Chapter 3 Control Flow. Chapter 3 - Control Flow The control-flow of a language specify the order in which computations are performed.
LOOPS CHAPTER Topics  Four Types of Loops –while –do…while –for –foreach  Jump Statements in Loops –break –continue 2.
Conditional Statements A conditional statement lets us choose which statement will be executed next Conditional statements give us the power to make basic.
This is a while loop. The code is done while the condition is true. The code that is done is enclosed in { }. Note that this program has three parts: Housekeeping.
CS 106 Introduction to Computer Science I 02 / 15 / 2008 Instructor: Michael Eckmann.
Looping I (while statement). CSCE 1062 Outline  Looping/repetition construct  while statement (section 5.1)
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. 4 Simple Flow of Control.
PHP Condtions and Loops Prepared by Dr. Maher Abuhamdeh.
Topic : While, For, Do-While Loop Guided By : Branch : Batch :
Chapter 5 - Control Structures: Part 2
Chapter 4 - Program Control
Think What will be the output?
Topics Introduction to Repetition Structures
ITM 352 Flow-Control: Loops
Introduction to MATLAB
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.
Iteration with While You can say that again.
For & do/while Loops.
Outline Altering flow of control Boolean expressions
Introduction to Programming
Laptop Instrument Meeting 22 April 11, 2018.
Lecture Notes – Week 3 Lecture-2
Laptop Instrument Meeting 4 January 29, 2018.
Arrays Chapter 8 Copyright © 2008 W. W. Norton & Company.
Iteration: Beyond the Basic PERFORM
LOOPS BY: LAUREN & ROMEO.
Module 4 Loops.
Program Control Topics While loop For loop Switch statement
IF Statements.
CHAPTER 21 LOOPS 1.
The for-statement.
Building Java Programs
Lec 21 More Fun with Arrays: For Loops
REPETITION Why Repetition?
Presentation transcript:

Laptop Instrument Meeting 7 February 7, 2018

The Note Chart Excel spreadsheet Columns for Helmholtz note name ASA note name ChucK note name MIDI number Frequency Acoustical Society of America

From Before Program to play a note, specified by frequency Program to play random notes Program to play octaves Program to play harmonic series Programs doing arithmetic

Control Structures Ways to control the order of execution of the statements. while ( condition ) { statements } if ( condition ) { statements } else { statements } for ( start ; condition ; increment ) { statements } statements means statement; statement; … statement;

Comparisons freq < 1000.0 i <= 10 J >= 5 Foo == 23.0

While statement Action, or effect is Check condition If true, execute the statements enclosed in { } Etc. If the condition never becomes false, the loop never stops. Ctrl C stops the program

For loop for ( start ; condition ; increment ) { statements } start: Declare a “loop” variable and initialize it. 1 => int i; //Starts the loop at 1 increment: Calculate the new value of the loop variable 2 +=> i; //Increments by 2 condition: Test the loop variable to stop iterating i <= 25;

Exercise Write a ChucK program that counts by threes starting at 5 and stopping just before 100. Have the program print each of the count values.

Exercise Write a ChucK program that prints the first 20 Fibonacci numbers. Let’s agree that f0 = 1 and f1 = 1. Then f2 = f0 + f1, f3 = f1 + f2, etc.

Exercise Enhance your Fibonacci program to present the output in well-labeled form: f0 = 1 f1 = 1 f2 = 2 f3 = 3 f4 = 5 etc

Exercise Modify your octave program so that it: Uses the sine oscillator Starts with a frequency of 27.5 Hz, the lowest note on the piano, an A Plays in turn, each for one second, all the A’s on the piano from lowest to highest Echoes to the screen the octave number and the frequency of the A.

Properties of a Note Notes in ChucK