CS 1430: Programming in C++ No time to cover HiC.

Slides:



Advertisements
Similar presentations
Chapter 9 – One-Dimensional Numeric Arrays. Array u Data structure u Grouping of like-type data u Indicated with brackets containing positive integer.
Advertisements

Do-while Loops Programming. COMP102 Prog Fundamentals I: do-while Loops /Slide 2 The do-while Statement l Syntax do action while (condition) l How it.
1 C++ Functions. // The function computes and returns the gross pay // based on the pay rate and hours. Hours over // 40 will be paid 1.5 times the regular.
CMPUT 101 Lab # 5 October 22, :00 – 17:00.
1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
1 9/28/07CS150 Introduction to Computer Science 1 Loops section 5.2, 5.4, 5.7.
1 10/20/08CS150 Introduction to Computer Science 1 do/while and Nested Loops Section 5.5 & 5.11.
1 10/11/06CS150 Introduction to Computer Science 1 do/while and Nested Loops.
CS 1400 Chapter 5, section 2. Loops! while (rel-expression)while (rel-expression) {statements statement } if the relational-expression is true, execute.
1 Lecture 14 Chapter 6 Looping Dale/Weems/Headington.
Summary of Loops Programming. COMP102 Prog Fundamentals I: Summary of Loops /Slide 2 Which Loop to Use? l for loop n for calculations that are repeated.
Administrative MUST GO TO CORRECT LAB SECTION! Homework due 11:59pm on Tuesday. 25 points off if late (up to 24 hours) Cannot submit after 11:59pm on Wednesday.
1 CS 1430: Programming in C++. 2 Input: Input ends with -1 Sentinel-Controlled Loop Input: Input begins with.
1 CS 1430: Programming in C++. 2 Literal Values Literal values of int Literal values of float
CS 2430 Day 1. Agenda Load NetBeans Introduction Syllabus Review some array operations.
1 CS 1430: Programming in C++. 2 IF Statement if (cond) statement //Next statement if (cond) { statement1 statement2 … } //Next statement.
1 09/20/04CS150 Introduction to Computer Science 1 Let ’ s all Repeat Together.
Chapter 6 Looping CS185/09 - Introduction to Programming Caldwell College.
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.
Review Binary Numbers Bit : 0 or 1 Byte: 8 bites 256 different values 2 8 KB : 1024 bytes 2 10 bytes MB : 1024 * 1024 bytes 2 10 * 2 10 (2 20 ) bytes GB.
1 C++ Loops Sentinel Controlled Count Controlled EOF Controlled.
1 CS1430: Programming in C++ Section 2 Instructor: Qi Yang 213 Ullrich
1 CS 1430: Programming in C++. 2 Find Max, Min, Average of m Sections Max, Min and Average of each section Max, Min and Average of all sections together.
1 CS 1430: Programming in C++. Quiz Functions Function Prototype float sqrt(float x); Function name, type, parameter and parameter type Function.
1 CS 1430: Programming in C++. 2 C++ Loops Sentinel Controlled Count Controlled EOF Controlled.
1 CS 1430: Programming in C++. 2 Input: Input ends with -1 Sentinel-Controlled Loop Input: Input begins with.
CS 1430: Programming in C++ Function Design 1. Good Functions Focusing on one thing Function name tells what it does sqrt(val) pow(base, exp) cin.eof()
1 CS1430: Programming in C++ Section 2 Instructor: Qi Yang 213 Ullrich
CS 1430: Programming in C++ 1. Test 2 Friday Functions Arrays For Loops Understand Concepts and Rules Memorize Concepts and Rules Apply Concepts and Rules.
1 Functions Function Prototype float sqrt(float x); Function name, type, parameter and parameter type Function Definition float sqrt(float x) { // compute.
CS 1430: Programming in C++.
Arrays float Scores[9]; ? index: element // one dimensional array 1.
Chapter 4 Repetition Statements Program Development and Design Using C++, Third Edition.
Selection (if-then-else) Programming Has 3 Types of Control: Sequential (normal): Control of Execution Proceeds One after the Other Selection (if-then-else):
Reference and Value Parameters Reference Parameters (&) The formal parameter receives the address of the actual parameter, and the function can read and.
C++ Iterative Constructs
CS 1430: Programming in C++ No time to cover HiC.
CS 1430: Programming in C++.
CS 1428 Exam II Review.
CS 1430: Programming in C++.
Scope of Variables The region of code where it is legal to reference (use) an identifier. Local Scope Global Scope Class Scope.
COMPUTER 2430 Object Oriented Programming and Data Structures I
CS 1430: Programming in C++.
Student Data Score First Name Last Name ID GPA DOB Phone ...
CS 1430: Programming in C++.
CS 1430: Programming in C++ Turn in your Quiz1-2 No time to cover HiC.
CS 1428 Exam II Review.
Lesson 05: Iterations Topic: Introduction to Programming, Zybook Ch 4, P4E Ch 5. Slides on website.
Flow of Control October 16, 2017.
CS 1430: Programming in C++ No time to cover HiC.
CS 1430: Programming in C++ No time to cover HiC.
Intro to Nested Looping
Repetition Control Structure
Standard Input/Output Stream
CS 1430: Programming in C++.
CS150 Introduction to Computer Science 1
Intro to Nested Looping
CS150 Introduction to Computer Science 1
Looping III (do … while statement)
Let’s all Repeat Together
CS150 Introduction to Computer Science 1
do/while Selection Structure
CS150 Introduction to Computer Science 1
Midterm Review October 23, 2006 ComS 207: Programming I (in Java)
Based on slides created by Bjarne Stroustrup & Tony Gaddis
Announcements Lab 3 was due today Assignment 2 due next Wednesday
Functions Divide and Conquer
Bell Work Each Friday, students will be given a bell work quiz consisting of one question from each day’s bell work that week. On the following slides.
CS 1430: Programming in C++.
Presentation transcript:

CS 1430: Programming in C++ No time to cover HiC

Tracing Range Known Tracing Input: 48 54 66 53 59 -1 const int LOW_LIMIT = 0; const int HIGH_LIMIT = 60; int score, max = LOW_LIMIT; cin >> score; while (score != -1) { if (score < LOW_LIMIT || score > HIGH_LIMIT) cout << “Invalid score: ” << score; else if (score > max) max = score; } Tracing Input: 48 54 66 53 59 -1 score max ? 0 48 54 66 53 59 -1 How to do it? One statement each line Do not cross old values Blank when no new value WILL BE ON QUIZ And Test 1 And Final!

Quiz3-2 10 Minutes

Write C++ Statements // Decrease theCount by 2 until theCount is negative. while ( theCount >= 0 ) { theCount -= 2; } // Another way while ( !(theCount < 0) ) // Incorrect! while ( theCount !< 0 ) while ( theCount > 0 ) Slides 21-23 could be moved to an earlier note

Write C++ Statements // While theValue is not positive, increase its value by 5. while ( theValue <= 0 ) { theValue += 5; } // Another way while ( !(theValue > 0) ) // Incorrect! while ( theValue < 0 )

Write C++ Statements DeMorgan’s Law // While theValue is not positive and theCount is // less than 10, increase theValue by 5 and theCount by 1. while ( theValue <= 0 && theCount < 10 ) { theValue += 5; theCount ++; } // increase theValue by 5 and theCount by 1 // until theValue is positive or theCount is 10 or higher. while ( !(theValue > 0 || theCount >= 10) ) // The same? DeMorgan’s Law

Example int someValue = 0; int i = 0; while (i < 10) { int j = 0; while (j < 5) someValue += i * j; // A j ++; } i ++; How many times is statement A executed? 10 5 50 15 None of above 50

Example int count = 0; int i = 0; while (i < 10) { int j = 5; while (j > 0) count ++; j --; } i ++; What is the final value of count? 10 20 50 100 None of above 50

Example int total = 0; int i = 5; while (i > 0) { int j = i; while (j > 0) total += j; j --; } i --; What is the final value of total? 15 25 35 45 None of above 35

Tracing Nested Loops int xValue, yValue, zValue; xValue = 3; while (xValue > 1) { zValue = 1; yValue = xValue; while (yValue > 0) zValue *= yValue; yValue --; } cout << "What is this: " << zValue; xValue --; xValue yValue zValue ? ? ? 3 1 2 6

Schedule Quiz3-3 Lab3 Prog1 Due 10 pm today Due 5 pm Thursday Past Due already Grace Time: 10 pm Friday

Schedule Prog2 Test 1 Nested loops Started Tuesday, 9-22 Friday, October 2 60 points If, While, and Others

Getting Help Pals 9 – 3 pm, Thursdays Lab Assistants 6 – 9 pm, Mon - Thur Come to me for help Name your file: UserName_Lab/ProgX Drop your program in K:\Courses\CSSE\yangq\Dropbox

You can still receive 15 points on Prog1!