Announcements Exam 1 Grades Posted on blackboard Average: 83.26

Slides:



Advertisements
Similar presentations
While Loops Programming. COMP102 Prog Fundamentals I: while Loops/Slide 2 Shortcut Assignments l C++ has a set of shortcut operators for applying an operation.
Advertisements

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 5, 2005.
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
Announcements Quiz 1 Posted on blackboard Handed Back (and Gone Over)Next Monday “Only a Quiz” Counts 5% of Final Grade Exam 1 Counts 10%
Chapter 5: Control Structures II (Repetition)
1 CS 105 Lecture 4 Selection Statements Wed, Jan 26, 2011, 6:05 pm.
Repetition. Examples When is repetition necessary/useful?
1 CS 105 Lecture 6 While Loops Wed, Feb 16, 2011, 5:13 pm.
COMP 14 Introduction to Programming Miguel A. Otaduy May 20, 2004.
CHAPTER 2 ANALYSIS OF ALGORITHMS Part 2. 2 Running time of Basic operations Basic operations do not depend on the size of input, their running time is.
1 Chapter 6 Repetition. 2 Outline & Objectives Loop Structure Loop Structure Elements of a Loop Structure Elements of a Loop Structure Processing Lists.
1 CS 105 Lecture 7 For & Do-While Loops Sun, Feb 27, 2011, 2:16 pm.
Chapter 4: Control Structures II
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 8 - JavaScript: Control Structures I Outline 8.1 Introduction 8.2 Algorithms 8.3 Pseudocode 8.4.
Lecture 10: Reviews. Control Structures All C programs written in term of 3 control structures Sequence structures Programs executed sequentially by default.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
More on Input Output Input Stream : A sequence of characters from an input device (like the keyboard) to the computer (the program running). Output Stream.
Selection (if-then-else) Programming Has 3 Types of Control: Sequential (normal): Control of Execution Proceeds One after the Other Selection (if-then-else):
Problem Solving and Control Statements. Using Exit to Terminate Repetition Statements There are many forms of the Exit statement, designed to terminate.
Quiz Answers 1. Show the output from the following code fragment: int a = 5, b = 2, c = 3; cout
Chapter 5: Control Structures: Iteration Visual Basic.NET Programming: From Problem Analysis to Program Design.
The for Loop Syntax: for ( expression1 ; condition ; expression2 ) statement ; for ( expression1 ; condition ; expression2 ) { statement ; } Same as: expression1.
Announcements Exam 1 Tuesday July minutes 10 % of Total Grade Covers Everything through Lecture 05. –Includes Quiz 1 Topics (terminology, variables,
1 09/20/04CS150 Introduction to Computer Science 1 Let ’ s all Repeat Together.
While Loops Programming. COMP102 Prog Fundamentals I: while Loops/Slide 2 Shortcut Assignments l C++ has a set of shortcut operators for applying an operation.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements I.
Control Statements in C 1.Decision making statements 2.Looping statements 3.Branching statements
Looping Construct or Statements. Introduction of looping constructs In looping,a sequence of statements are executed until some condition for termination.
Chapter 5: Control Structures: Iteration Visual Basic.NET Programming: From Problem Analysis to Program Design.
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.
CONTROL STATEMENTS LOOPS. WHY IS REPETITION NEEDED?  There are many situations in which the same statements need to be executed several times.  Example:
CONTROL STRUCTURE Chapter 3. CONTROL STRUCTURES ONE-WAY SELECTION Syntax: if (expression) statement Expression referred to as decision maker. Statement.
Program Structures Chapter 5. 5 Branching Allows different code to execute based on a conditional test. if, if-else, and switch statements.
Midterm 2 Review. Stars and why we use nested loops  Matrix problems (stars)  Other problems involving multiple dimensions  Loops within a process.
CSC 4630 Meeting 17 March 21, Exam/Quiz Schedule Due to ice, travel, research and other commitments that we all have: –Quiz 2, scheduled for Monday.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Lecture 5: Layers of Control. Nested while Loops Problem Multiplying two numbers and outputting the result only if they are both less than 5. (i.e. Start.
CSC 4630 Perl 3 adapted from R. E. Beck. Problem But we worked on it first: Input: Read from a text file named in a command line argument Output: List.
Computer Program Flow Control structures determine the order of instruction execution: 1. sequential, where instructions are executed in order 2. conditional,
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 3 - Structured Program Development Outline.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Flow Control (while) Outline 3.7The While Repetition.
Selection (if-then-else) Programming Has 3 Types of Control: Sequential (normal): Control of Execution Proceeds One after the Other Selection (if-then-else):
Quiz 1 Exam 1 Next Monday. Nested if Statements if (myGrade >= 80) if (myGrade >= 90) System.out.println(“You have an A!” ); else System.out.println(“You.
JavaScript: Control Structures I Outline 1 Introduction 2 Algorithms 3 Pseudocode 4 Control Structures 5 if Selection Structure 6 if/else Selection Structure.
More about Iteration Victor Norman CS104. Reading Quiz.
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
Announcements Quiz 1 Posted on blackboard
Think What will be the output?
Ch 7: JavaScript Control Statements I.
3rd prep. – 2nd Term MOE Book Questions.
Announcements Exam 1 Grades Posted on Blackboard.
Selection (if-then-else)
Structured Program
Chapter (3) - Looping Questions.
3 Control Statements:.
Announcements Exam 1 Thursday 50 minutes 10 % of Total Grade
Control Statements Loops.
Announcements Exam 1 Thursday Everything through Lab 5 50 minutes
Announcements Exam 1 Grades Posted on Blackboard.
The for Loop Syntax: Same as: for (expression1;condition; expression2)
Three Special Structures – Case, Do While, and Do Until
Let’s all Repeat Together
A LESSON IN LOOPING What is a loop?
Control Statements Loops.
(Dreaded) Quiz 2 Next Monday.
Announcements Lab 3 was due today Assignment 2 due next Wednesday
Hossain Shahriar CISC 101: Fall 2011 Hossain Shahriar
Announcements Exercise Sets 2 and 3 Due Thursday.
Challenge Guide Grade Code Type Slides
Presentation transcript:

Announcements Exam 1 Grades Posted on blackboard Average: 83.26 Median: 86 High: 99(4)

Iteration Iteration (Looping): Performing a Series of Statements Multiple Times until Some Condition Is Met. Eliminates the Need for Redundant Coding or Function Calls

The while Loop Syntax: while condition statement; end

while Example MAX = 100; counter = 0; while counter < MAX disp(counter); counter = counter + 1; end

Example while Loop numEmployees = input('Enter Number of Employees: '); if numEmployees > 0 curNum = 0; while curNum < numEmployees disp('Welcome to CorpLand!'); curNum = curNum + 1; end %while end %if

Example while Loop numEmployees = input('Enter Number of Employees: '); if numEmployees > 0 curNum = 0; while curNum < numEmployees disp('Welcome to CorpLand!'); curNum = curNum + 1; end %while end %if

The for Loop Syntax: Same as: for starting assignment:step: terminating value statement end Same as: starting assignment; while variable <= terminating value variable = variable + step;

Example for Loop numEmployees = input('Enter Number of Employees: '); if numEmployees > 0 for curNum = 1:1:numEmployees disp('Welcome to CorpLand!'); end else disp('Hmmmmm!!!');

Example for Loop numEmployees = input('Enter Number of Employees: '); if numEmployees > 0 for curNum = 1:numEmployees %step assumed to be 1 disp('Welcome to CorpLand!'); end else disp('Hmmmmm!!!');

Looping for Input stringEntered = 'go'; while ~strcmp(stringEntered,'stop') stringEntered = input('Enter a string: ','s'); end

Nested Loops for k = 1 : 10 for l = 1 : 10 out1 = sprintf('%d%d ',k,l); disp(out1); end

Quiz 2 Need to Know : Loops : while , for No Terminology on Quiz 2