CSE100 Principles of Programming with C++

Size: px
Start display at page:

Download "CSE100 Principles of Programming with C++"

Transcription

1 1 Instructions You may work in pairs (that is, as a group of two) with a partner on this lab project if you wish or you may work alone. If you work with a partner, only submit one lab project with both of your names in the source code file to Blackboard for grading; you will each earn the same number of points. What to hand in, and by when, is discussed in Section 7; read it now. 2 Lab Objectives After completing this assignment the student should be able to, Complete all of the objectives of the previous lab projects. Write programs using while and for loops. Write programs consisting of functions defined in multiple source code files. Write function prototypes in header files and include header files when required. 3 Background 3.1 Newton's Method [Ref: Wikipedia: Newton's Method] Newton's method is a mathematical algorithm that can be used to find the roots of a real-valued function, i.e., the roots are real numbers. For example, consider the 2nd-degree polynomial function p(x) = 2.1x x and its plot, Clearly p(x) has two real roots: the first one, root 1, is around 0.45 and the second one, root 2, is near 6.5. Since p(x) is a second degree polynomial equation, i.e., a quadratic, we could use the well-known quadratic formula to find the roots, but we could also find the roots using Newton's method. Newton's method is an iterative method, i.e., it involves a loop. Here is the pseudocode for Newton's method which finds a root of f(x) where f(x) is any real-valued function, function newtons_method (f(x) is a real-valued function, ε is a double) double x i guess a value for the root we are trying to find x i+1 x i - f(x i ) / f'(x i ) -- evaluate f(x) at x i and evaluate the first derivative, f'(x), at x i while x i+1 - x i ε do x i x i+1 x i+1 x i - f(x i ) / f'(x i ) end while return x i+1 The parameter ε is a small number which controls how accurate the returned value is. For example, if we desire the returned value to be correct to three digits after the decimal point, then we would pass = as ε. If we passed 10-9 = for ε, the returned value would be accurate to at least eight digits after the decimal point. In general, if ε is 10 -p, the accuracy will be p - 1 correct digits after the decimal point. The smaller ε is, the more accurate the result, but this accuracy comes at the expense of performing more iterations to find the root, i.e., it takes longer. Note that in C++, we can represent real numbers in exponential notation, which is similar to scientific notation. For example, would be represented as E-78, where the E represents "times 10 to the" and the exponent is written after the E. Consequently, if we wished to use for ε, we would write 1E- 16. (c) Kevin R. Burger :: Computer Science & Engineering :: Arizona State University Page 1

2 Note that Newton's method starts by initializing x i to some value that is basically a guess for where we think the root is. The more accurate this guess, the more quickly Newton's method will converge to the correct answer. For a function with more than one root, e.g., our p(x) function from above, this initial guess will affect which root (the one near 0.45 or the one near 6.5) is found. For exam - ple, if x i were initialized to 0 then Newton's method is going to converge on the root near On the other hand, if we guessed 100 for x i then it will converge to the root near 6.5. The loop iterates until the absolute value of the difference between the prior value of x (x i) and the current value of x (x i+1 ) is less than ε. Each time through the loop, a new value (x i+1 ) for the root we are searching for is calculated by subtracting from the prior value (x i) the quotient of dividing f(x) evaluated at x i by the first derivative of f(x) evaluated at x i. (If you want to understand the mathematics behind Newton's method, i.e., why it works, refer to the Wikipedia page referenced above or any calculus text book). In my day, Newton's method was learned in Calculus II. We are going to use Newton's method in this lab project to write a function that computes and returns the a th root of a real number n, i.e., a n We will discuss how the algorithm works, using the square root of n = 17 (a = 2) as the example. If x = n then, x 2 = n which we can write as, x 2 n = 0 If we define f(x) = x 2 - n, then we can use Newton's method to find the positive root of f(x), which will be the square root of n. For example, let's trace newtons_method() for f(x) = x 2-17 and ε = 1E-4 = , i.e., we are going to find the square root of n = 17 with at least three digits of accuracy after the decimal point. Note that f'(x) = 2x. Let's use n / 2 as our starting guess because the square root of n will be between 1 and n / 2 (accurate digits of x i+1 are underlined), x i x i+1 x i+1 - x i Difference is > ε so keep looping Difference is > ε so keep looping Difference is > ε so keep looping Difference is > ε so keep looping x i+1 - x i < ε = so return x i+1 Notice how each new value of x i+1 is closer to the root than the previous value x i. If Newton's method is going to converge, the absolute value of the difference of x i+1 and x i will become smaller and smaller, until it is less than ε (in theory, the difference will go to 0 but the double data type cannot represent real numbers with more than digits of accuracy). Consequently, newtons_ method() would return (the underlined digits are all accurate) for the square root of 17. The correct value to 25-digits is (the correct value is a non-terminating fraction, i.e., it goes on forever) and the absolute value of the difference between the correct value to 25-digits and what newtons_method() returns is approximately , which is our error. Therefore, newtons_method() returned a value that is correct to = 13 digits after the decimal point and it only took four iterations of the while loop to do it. In general, to find the a th root of n, a 2, we define f(x) = x a - n where f'(x) = ax a-1. The pseudocode for our function (named ath_root) is, function ath_root(n 0 is a double, a 2 is an integer, ε is a double) double x_i n / 2 -- initial guess x_i_plus_1 x_i - (x_i a - n) / (a x_i a-1 ) while x_i_plus_1 - x_i ε do -- notice this is a sentinel loop with the sentinel being a value less than ε x_i x_i_plus_1 x_i_plus_1 x_i - (x_i a - n) / (a x_i a-1 ) end while return x_i_plus_1 (c) Kevin R. Burger :: Computer Science & Engineering :: Arizona State University Page 2

3 We have to make a guess for the initial value of x i so we will use n divided by 2. I believe, but have not verified, that this initial value will cause Newton's Method to always converge to the a th root. 3.2 Fibonacci Numbers [Ref: Wikipedia: Fibonacci Numbers] The Fibonacci numbers (also referred to as the Fibonacci sequence) is this sequence of integers, where, 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377,... 1 f 0 = 0 f 1 = 1 f n = f n f n - 1 when n > 1 That is, the first two Fibonacci numbers are 0 and 1 and each successive number in the sequence is the sum of the two previous numbers. We can write a function to compute and return the n th Fibonacci number (n 0), i.e., fib n by employing a for loop. Here is the pseudocode for the function, function nth_fib(n 0 is an long) long fib_n n if n > 1 then fib_n_minus_2 0 fib_n_minus_1 1 for i 2 to n do -- notice this is a counting loop that executes n - 1 times fib_n fib_n_minus_2 + fib_n_minus_1 -- fib n is the sum of fib n-2 + fib n-1 fib_n_minus_2 fib_n_minus_1 fib_n_minus_1 fib_n end for end if return fib_n I suggest you trace this function for various values of n to convince yourself that you understand how it works. Note: C++ has more than one basic data type for representing integers. We have been using int all semester, but there is also an integer data type named long. The difference between the int and long data types is that the size of a long value, i.e., the number of binary bits that are allocated to represent the long integer, is guaranteed to be either the same size as int or larger. If 32-bits are allocated for int (as it commonly is), then we can represent decimal integers in the range [-2 31, ], which is [-2,147,483,648 to 2,147,483,647]. Depending on the word size of your computer and the C++ compiler being used (a 64-bit compiler versus a 32-bit compiler) a long integer will generally either be 32- or 64-bits. Using 64-bits to represent signed integers gives us a range of [-2 63, ], which is approximately ± x 10 18, which is around [-9,223,372,037,000,000,000 to 9,223,372,037,000,000,000]. 4 Lab Exercise Software Requirements The program shall display a menu with three menu items, Choice? 1 and prompt the user to select menu item 1, 2, or 3. If the user selects menu item 1, the program shall prompt the user to enter values for n and a, Your choice is to compute the a-th root of n. Enter n (>= 0): Enter a (>= 2): 5 The 5-th root of is Note, the starting values for the Fibonacci sequence are not always listed as 0 and 1. I have seen books refer to the sequence 1, 1, 2, 3, 5,... Also, the first Fibonacci number is not always denoted by f 0. Hence, an alternative sequence is f 1 = 1, f 2 = 1, f 3 = 2,... (c) Kevin R. Burger :: Computer Science & Engineering :: Arizona State University Page 3

4 and it shall compute and display the a th root of n (configure cout to display real number in fixed notation with 16 digits after the decimal point). After displaying the result, the program shall display the menu again, Choice? 2 and prompt the user to select menu item 1, 2, or 3. If the user selects menu item 2, it shall prompt the user to enter a value for n, Your choice is to compute the n-th Fibonacci number. Enter n (>= 0): 22 The 22-th Fibonacci number is and shall display the n th Fibonacci number. After displaying the result, the program shall display the menu again. It shall continue this process of displaying the menu, performing the selected operation when menu items 1 or 2 are selected. When the user selects menu item 3, the program shall terminate, Choice? 2 Your choice is to compute the n-th Fibonacci number. Enter n (>= 0): 22 The 22-th Fibonacci number is Choice? 2 Your choice is to compute the n-th Fibonacci number. Enter n (>= 0): 46 The 46-th Fibonacci number is Choice? 3 Bye. 5 Software Design The program shall consist of two.cpp files: Lab12.cpp and MyMath.cpp and a header file named MyMath.hpp. The contents of Lab12.cpp shall be implemented using the pseudocode shown below. Note that we use a sentinel loop in main() to continue displaying the menu and reading the user's choice, until the user selects menu item 3 to quit. This means that MENU_ITEM_3_QUIT is the sentinel value for the loop. Remember, a sentinel loop always has two read operations: the first read operation occurs before the loop begins and reads the first value from the sequence, i.e., the first selected menu item; the second read operation occurs at the end of the body of the loop and reads the next value from the sequence, i.e., the next selected menu item. define integer constant MENU_ITEM_1_ROOT 1 define integer constant MENU_ITEM_2_FIB 2 define integer constant MENU_ITEM_3_QUIT 3 define real constant EPSILON 1E E-16 means , where the E stands for "times ten to the". function compute_ath_root() nothing send "Your choice is to compute the a-th root of a number." to cout n get_double("enter n (>= 0): ") (c) Kevin R. Burger :: Computer Science & Engineering :: Arizona State University Page 4

5 a get_int("enter a (>= 2): ") root ath_root(n, a, EPSILON) send "The " a "-th root of " n " is " root to cout function compute_nth_fib() nothing send "Your choice is to compute the n-th Fibonacci number." to cout n get_long("enter n (>= 0): " fib_n nth_fib(n) send "The " n "-th Fibonacci number is " fib_n to cout function get_double(prompt is a string) double send prompt to cout read a double from the keyboard into n return n function get_int(prompt is a string) int send prompt to cout read an int from the keyboard into n return n function get_long(prompt is a string) long send prompt to cout read a long from the keyboard into n return n function menu() int send "" to cout send "" to cout send "" to cout send "" to cout choice get_int("choice? ") return choice function main() int configure cout to display real numbers in fixed notation with 16 digits after the decimal point choice menu() -- this read operation reads the first value in the sequence while choice = MENU_ITEM_3_QUIT do if choice = MENU_ITEM_1_ROOT then compute_ath_root() else -- choice must be MENU_ITEM_2_FIB compute_nth_fib() end if choice menu() -- this read operation reads the next value in the sequence (c) Kevin R. Burger :: Computer Science & Engineering :: Arizona State University Page 5

6 end while send "Bye." to cout return 0 The contents of MyMath.cpp shall be the two functions ath_root() and nth_fib() for which the pseudocode was presented earlier. Because we call these two functions from functions in Lab12.cpp, we must have prototypes in Lab12.cpp for the two functions; the prototypes are required to give the compiler the information it needs to know about the functions so it can compile the lines of code where we call the functions. If we place the prototypes in a header file named MyMath.hpp, then we can #include MyMath.hpp in Lab12.cpp, which would make the prototypes available to the compiler. Read the comments in MyMath.hpp to implement it. 6 Additional Programming Requirements 1. Add a comment header block at the top of each source code file with your name (and your partners name if applicable), address (and your partner's address if applicable), the lab number, your lab date/time, and your lab TA. 2. Carefully format your code and follow the indentation of the text as shown in the example programs of the textbook. 7 What to Submit for Grading and by When When you are finished with the program, create a new empty folder named Lab12. Copy Lab12.cpp, MyMath.hpp, and MyMath.cpp to this folder; there should only be these three files in this folder. Then compress this folder creating a zip archive named cse100-s17- lab12-auriteid.zip where asuriteid is your ASU user name that you use to log in to Blackboard, e.g., mine is kburger2. If you worked with a partner then name the zip archive cse100-s17-lab12-auriteid1-asurite2.zip where asurite1 and asurite2 are the user names of both partners. Then upload the.zip archive file to Blackboard using the lab submission link by the deadline. If your program does not compile or run correctly, upload what you have completed for grading anyway (you will generally receive some partial credit for effort). The deadline for the complete lab project is 4:00am Sat 29 Apr. Consult the online syllabus for the late and academic integrity policies. 8 Grading Rubric 1. Lab Exercise Program (0 to 5 pts) Testing the Program: Compile and run the student's program using these test cases: Test Case 1: The cube root of is Test Case 2: The 5th root of 173 is Test Case 3: The 18 root of is Test Case 4: fib(0) is 0. Test Case 5: fib(1) is 1. Test Case 6: fib(5) is 5. Test Case 7: fib(41) is a. If the submitted program does, or does not, compile and the student completed less than 50% of the required code correctly, assign +2 pts. b. If the submitted program does not compile and the student completed more than 50% of the required code correctly, assign +3 pts. c. If the submitted program compiles and the student completed more than 50% of the required code correctly, assign +4 pts. d. If the submitted program compiles and is implemented perfectly, or close to perfect with only one or two minor mistakes, assign +5 pts. 2. Deadline was 4:00am Sat 29 Apr. a. Assign 20% bonus calculated on the earned pts for a submission prior to 4:00am Thu 27 Apr. b. Assign 10% bonus calculated on the earned pts for a submission between 4:00am Thu 27 Apr and 3:59am Fri 28 Apr. c. Deduct 10% (-0.5 pts) for a submission between 4:00am Sat 29 Apr and 3:59am Sun 30 Apr. d. Deduct 20% (-1.0 pt) for a submission after 4:00am Sun 30 Apr. (c) Kevin R. Burger :: Computer Science & Engineering :: Arizona State University Page 6

CSE/EEE 230 Computer Organization and Assembly Language

CSE/EEE 230 Computer Organization and Assembly Language 1 Instructions You may work in pairs with one partner on this assignment if you wish or you may work alone. If you work with a partner, only submit one file to Blackboard with both of your names in the

More information

Computational Mathematics/Information Technology. Worksheet 2 Iteration and Excel

Computational Mathematics/Information Technology. Worksheet 2 Iteration and Excel Computational Mathematics/Information Technology Worksheet 2 Iteration and Excel This sheet uses Excel and the method of iteration to solve the problem f(x) = 0. It introduces user functions and self referencing

More information

Project 1. due date Sunday July 8, 2018, 12:00 noon

Project 1. due date Sunday July 8, 2018, 12:00 noon Queens College, CUNY, Department of Computer Science Object-oriented programming in C++ CSCI 211 / 611 Summer 2018 Instructor: Dr. Sateesh Mane c Sateesh R. Mane 2018 Project 1 due date Sunday July 8,

More information

The Bisection Method versus Newton s Method in Maple (Classic Version for Windows)

The Bisection Method versus Newton s Method in Maple (Classic Version for Windows) The Bisection Method versus (Classic Version for Windows) Author: Barbara Forrest Contact: baforres@uwaterloo.ca Copyrighted/NOT FOR RESALE version 1.1 Contents 1 Objectives for this Lab i 2 Approximate

More information

Fortran 90 Two Commonly Used Statements

Fortran 90 Two Commonly Used Statements Fortran 90 Two Commonly Used Statements 1. DO Loops (Compiled primarily from Hahn [1994]) Lab 6B BSYSE 512 Research and Teaching Methods The DO loop (or its equivalent) is one of the most powerful statements

More information

Repetition Structures

Repetition Structures Repetition Structures Chapter 5 Fall 2016, CSUS Introduction to Repetition Structures Chapter 5.1 1 Introduction to Repetition Structures A repetition structure causes a statement or set of statements

More information

Condition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution.

Condition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution. Repetition Structures Introduction to Repetition Structures Chapter 5 Spring 2016, CSUS Chapter 5.1 Introduction to Repetition Structures The Problems with Duplicate Code A repetition structure causes

More information

GUIDED NOTES 3.1 FUNCTIONS AND FUNCTION NOTATION

GUIDED NOTES 3.1 FUNCTIONS AND FUNCTION NOTATION GUIDED NOTES 3.1 FUNCTIONS AND FUNCTION NOTATION LEARNING OBJECTIVES In this section, you will: Determine whether a relation represents a function. Find the value of a function. Determine whether a function

More information

Mathematical preliminaries and error analysis

Mathematical preliminaries and error analysis Mathematical preliminaries and error analysis Tsung-Ming Huang Department of Mathematics National Taiwan Normal University, Taiwan August 28, 2011 Outline 1 Round-off errors and computer arithmetic IEEE

More information

DEPARTMENT OF ACADEMIC UPGRADING

DEPARTMENT OF ACADEMIC UPGRADING DEPARTMENT OF ACADEMIC UPGRADING COURSE OUTLINE WINTER 2014 INTRODUCTION TO MATH 0081 INSTRUCTOR: Joelle Reynolds PHONE: (780) 539-2810 or 2204 OFFICE: Math Lab A210 E-MAIL: jreynolds@gprc.ab.ca OFFICE

More information

Algebraic Expressions

Algebraic Expressions P.1 Algebraic Expressions, Mathematical Models, and Real Numbers P.2 Exponents and Scientific Notation Objectives: Evaluate algebraic expressions, find intersection and unions of sets, simplify algebraic

More information

CS 352 : MIPS & Amicable Numbers

CS 352 : MIPS & Amicable Numbers CS 352 : MIPS & Amicable Numbers 1 MARS You will be using the MIPS Assembler and Runtime Simulator (MARS) for this lab assignment. Download: http://courses.missouristate.edu/kenvollmar/mars/download.htm

More information

Chapter 5. Repetition. Contents. Introduction. Three Types of Program Control. Two Types of Repetition. Three Syntax Structures for Looping in C++

Chapter 5. Repetition. Contents. Introduction. Three Types of Program Control. Two Types of Repetition. Three Syntax Structures for Looping in C++ Repetition Contents 1 Repetition 1.1 Introduction 1.2 Three Types of Program Control Chapter 5 Introduction 1.3 Two Types of Repetition 1.4 Three Structures for Looping in C++ 1.5 The while Control Structure

More information

MAT 003 Brian Killough s Instructor Notes Saint Leo University

MAT 003 Brian Killough s Instructor Notes Saint Leo University MAT 003 Brian Killough s Instructor Notes Saint Leo University Success in online courses requires self-motivation and discipline. It is anticipated that students will read the textbook and complete sample

More information

Helping Students Understand Pre-Algebra

Helping Students Understand Pre-Algebra Helping Students Understand Pre-Algebra By Barbara Sandall, Ed.D., & Mary Swarthout, Ph.D. COPYRIGHT 2005 Mark Twain Media, Inc. ISBN 10-digit: 1-58037-294-5 13-digit: 978-1-58037-294-7 Printing No. CD-404021

More information

ITERATION AND RECURSION 3

ITERATION AND RECURSION 3 ITERATION AND RECURSION 3 COMPUTER SCIENCE 61A June 26, 2012 1 Newton s Method Newton s method is an algorithm that is widely used to compute the zeros of functions. It can be used to approximate a root

More information

DEPARTMENT OF ACADEMIC UPGRADING

DEPARTMENT OF ACADEMIC UPGRADING DEPARTMENT OF ACADEMIC UPGRADING COURSE OUTLINE WINTER 2013 INTRODUCTION TO MATH 0081 INSTRUCTOR: Sukhvir Sandhu PHONE: (780) 539-2810 or 2234 OFFICE: Math Lab A210 or C310 E-MAIL: ssandhu@gprc.ab.ca OFFICE

More information

Faculty of Science, Engineering and Technology

Faculty of Science, Engineering and Technology Swinburne University of Technology Faculty of Science, Engineering and Technology ASSIGNMENT COVER SHEET Subject Code: COS30008 Subject Title: Data Structures and Patterns Assignment number and title:

More information

Reals 1. Floating-point numbers and their properties. Pitfalls of numeric computation. Horner's method. Bisection. Newton's method.

Reals 1. Floating-point numbers and their properties. Pitfalls of numeric computation. Horner's method. Bisection. Newton's method. Reals 1 13 Reals Floating-point numbers and their properties. Pitfalls of numeric computation. Horner's method. Bisection. Newton's method. 13.1 Floating-point numbers Real numbers, those declared to be

More information

Programming Project #2: Solving Quadratic Equations Date Due: Monday 25 September 2017

Programming Project #2: Solving Quadratic Equations Date Due: Monday 25 September 2017 CISC 5300 Programming in C++ Fall, 2017 Programming Project #2: Solving Quadratic Equations Date Due: Monday 25 September 2017 Write a program that prompts the user to enter the coefficients of a quadratic

More information

MS213: Numerical Methods Computing Assignments with Matlab

MS213: Numerical Methods Computing Assignments with Matlab MS213: Numerical Methods Computing Assignments with Matlab SUBMISSION GUIDELINES & ASSIGNMENT ADVICE 1 Assignment Questions & Supplied Codes 1.1 The MS213 Numerical Methods assignments require students

More information

Section 0.3 The Order of Operations

Section 0.3 The Order of Operations Section 0.3 The Contents: Evaluating an Expression Grouping Symbols OPERATIONS The Distributive Property Answers Focus Exercises Let s be reminded of those operations seen thus far in the course: Operation

More information

AP Statistics Summer Review Packet

AP Statistics Summer Review Packet 60 NAME: PERIOD: AP Statistics Summer Review Packet Teacher(s): Ryan Oben Teacher(s) Contact Information: Ryan_Oben@mcpsmd.org Course: Purpose of the Summer Assignment: In general, AP Statistics includes

More information

CSE/EEE 230 Computer Organization and Assembly Language

CSE/EEE 230 Computer Organization and Assembly Language 1 Instructions This assignment includes exercises covering assembly language procedures, discussed in Ch. 2, and the IEEE 754 floating point standard, which is discussed in the Ch. 3 lecture notes. First,

More information

Learning Packet. Lesson 6 Exponents and Rational Functions THIS BOX FOR INSTRUCTOR GRADING USE ONLY

Learning Packet. Lesson 6 Exponents and Rational Functions THIS BOX FOR INSTRUCTOR GRADING USE ONLY Learning Packet Student Name Due Date Class Time/Day Submission Date THIS BOX FOR INSTRUCTOR GRADING USE ONLY Mini-Lesson is complete and information presented is as found on media links (0 5 pts) Comments:

More information

1 of 34 7/9/2018, 8:08 AM

1 of 34 7/9/2018, 8:08 AM of 34 7/9/08, 8:08 AM Student: Date: Instructor: Alfredo Alvarez Course: Math 040 Spring 08 Assignment: Math 040 Homework3bbbbtsilittle. Graph each integer in the list on the same number line. 3, 3, 5,

More information

CS446: Machine Learning Fall Problem Set 4. Handed Out: October 17, 2013 Due: October 31 th, w T x i w

CS446: Machine Learning Fall Problem Set 4. Handed Out: October 17, 2013 Due: October 31 th, w T x i w CS446: Machine Learning Fall 2013 Problem Set 4 Handed Out: October 17, 2013 Due: October 31 th, 2013 Feel free to talk to other members of the class in doing the homework. I am more concerned that you

More information

CS321 Introduction To Numerical Methods

CS321 Introduction To Numerical Methods CS3 Introduction To Numerical Methods Fuhua (Frank) Cheng Department of Computer Science University of Kentucky Lexington KY 456-46 - - Table of Contents Errors and Number Representations 3 Error Types

More information

DEPARTMENT OF ACADEMIC UPGRADING

DEPARTMENT OF ACADEMIC UPGRADING DEPARTMENT OF ACADEMIC UPGRADING COURSE OUTLINE WINTER 2013 INTRODUCTION TO MATH 0081 INSTRUCTOR: Aidarus Farah PHONE: (780) 539-2810 OFFICE: Math Lab A210 E-MAIL: afarah@gprc.ab.ca OFFICE HOURS: &, 5:30

More information

CpSc 1011 Lab 4 Formatting and Flow Control Windchill Temps

CpSc 1011 Lab 4 Formatting and Flow Control Windchill Temps CpSc 1011 Lab 4 Formatting and Flow Control Windchill Temps Overview By the end of the lab, you will be able to: use fscanf() to accept inputs from the user and use fprint() for print statements to the

More information

Part 1: Group Brainstorm (NO computers during this time) Part 2: Submit Individual Brainstorm (You can now use a computer)

Part 1: Group Brainstorm (NO computers during this time) Part 2: Submit Individual Brainstorm (You can now use a computer) Part 1: Group Brainstorm (NO computers during this time) Good programmers think before they begin coding. Part I of this assignment involves brainstorming with a group of peers with absolutely no computers

More information

Standardized Tests: Best Practices for the TI-Nspire CX

Standardized Tests: Best Practices for the TI-Nspire CX The role of TI technology in the classroom is intended to enhance student learning and deepen understanding. However, efficient and effective use of graphing calculator technology on high stakes tests

More information

Spring 2017 CMSC 140 Programming Project 7: Payroll

Spring 2017 CMSC 140 Programming Project 7: Payroll Spring 2017 CMSC 140 Programming Project 7: Payroll Concepts tested by the program: 1. Working with arrays 2. Using file operations 3. Using a selection sort to sort parallel arrays 4. Using a binary search

More information

College Algebra Extra Credit Worksheet

College Algebra Extra Credit Worksheet College Algebra Extra Credit Worksheet Fall 011 Math W1003 (3) Corrin Clarkson Due: Thursday, October 0 th, 011 1 Instructions Each section of this extra credit work sheet is broken into three parts. The

More information

CSci 1113, Fall 2015 Lab Exercise 4 (Week 5): Write Your Own Functions. User Defined Functions

CSci 1113, Fall 2015 Lab Exercise 4 (Week 5): Write Your Own Functions. User Defined Functions CSci 1113, Fall 2015 Lab Exercise 4 (Week 5): Write Your Own Functions User Defined Functions In previous labs, you've encountered useful functions, such as sqrt() and pow(), that were created by other

More information

15-110: Principles of Computing, Spring 2018

15-110: Principles of Computing, Spring 2018 15-110: Principles of Computing, Spring 2018 Problem Set 5 (PS5) Due: Friday, February 23 by 2:30PM via Gradescope Hand-in HANDIN INSTRUCTIONS Download a copy of this PDF file. You have two ways to fill

More information

Here is the data collected.

Here is the data collected. Introduction to Scientific Analysis of Data Using Spreadsheets. Computer spreadsheets are very powerful tools that are widely used in Business, Science, and Engineering to perform calculations and record,

More information

CSCE 110 Dr. Amr Goneid Exercise Sheet (7): Exercises on Recursion

CSCE 110 Dr. Amr Goneid Exercise Sheet (7): Exercises on Recursion CSCE 110 Dr. Amr Goneid Exercise Sheet (7): Exercises on Recursion Consider the following recursive function: int what ( int x, int y) if (x > y) return what (x-y, y); else if (y > x) return what (x, y-x);

More information

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit. Com S 227 Fall 2017 Miniassignment 1 50 points Due Date: Monday, October 16, 11:59 pm (midnight) Late deadline (25% penalty): Tuesday, October 17, 11:59 pm General information This assignment is to be

More information

During the first 2 weeks of class, all students in the course will take an in-lab programming exam. This is the Exam in Programming Proficiency.

During the first 2 weeks of class, all students in the course will take an in-lab programming exam. This is the Exam in Programming Proficiency. Description of CPSC 301: This is a 2-unit credit/no credit course. It is a course taught entirely in lab, and has two required 2-hour 50-minute lab sessions per week. It will review, reinforce, and expand

More information

Chapter 1. Math review. 1.1 Some sets

Chapter 1. Math review. 1.1 Some sets Chapter 1 Math review This book assumes that you understood precalculus when you took it. So you used to know how to do things like factoring polynomials, solving high school geometry problems, using trigonometric

More information

EC121 Mathematical Techniques A Revision Notes

EC121 Mathematical Techniques A Revision Notes EC Mathematical Techniques A Revision Notes EC Mathematical Techniques A Revision Notes Mathematical Techniques A begins with two weeks of intensive revision of basic arithmetic and algebra, to the level

More information

Course of study- Algebra Introduction: Algebra 1-2 is a course offered in the Mathematics Department. The course will be primarily taken by

Course of study- Algebra Introduction: Algebra 1-2 is a course offered in the Mathematics Department. The course will be primarily taken by Course of study- Algebra 1-2 1. Introduction: Algebra 1-2 is a course offered in the Mathematics Department. The course will be primarily taken by students in Grades 9 and 10, but since all students must

More information

Lab Exercise 4: Inheritance and Polymorphism CS 2334

Lab Exercise 4: Inheritance and Polymorphism CS 2334 Lab Exercise 4: Inheritance and Polymorphism CS 2334 September 14, 2017 Introduction With this lab, we consider relationships between objects. Think about the records that we keep for every item used to

More information

Chapter 5. Radicals. Lesson 1: More Exponent Practice. Lesson 2: Square Root Functions. Lesson 3: Solving Radical Equations

Chapter 5. Radicals. Lesson 1: More Exponent Practice. Lesson 2: Square Root Functions. Lesson 3: Solving Radical Equations Chapter 5 Radicals Lesson 1: More Exponent Practice Lesson 2: Square Root Functions Lesson 3: Solving Radical Equations Lesson 4: Simplifying Radicals Lesson 5: Simplifying Cube Roots This assignment is

More information

SKILL: Fraction arithmetic and reducing fractions back to top

SKILL: Fraction arithmetic and reducing fractions back to top Table of Contents 050 Skills 1) Fraction Arithmetic 2) Check Solution 3) Graphing and Ordered Pairs 4) Finding Intercepts From a Graph 5) Solve a System of Equations 6) Evaluate an Expression with Exponents

More information

Programming Standards: You must conform to good programming/documentation standards. Some specifics:

Programming Standards: You must conform to good programming/documentation standards. Some specifics: CS3114 (Spring 2011) PROGRAMMING ASSIGNMENT #3 Due Thursday, April 7 @ 11:00 PM for 100 points Early bonus date: Wednesday, April 6 @ 11:00 PM for a 10 point bonus Initial Schedule due Thursday, March

More information

CSci 1113, Spring 2018 Lab Exercise 3 (Week 4): Repeat, Again and Again

CSci 1113, Spring 2018 Lab Exercise 3 (Week 4): Repeat, Again and Again CSci 1113, Spring 2018 Lab Exercise 3 (Week 4): Repeat, Again and Again Iteration Imperative programming languages such as C++ provide high-level constructs that support both conditional selection and

More information

1 of 39 8/14/2018, 9:48 AM

1 of 39 8/14/2018, 9:48 AM 1 of 39 8/14/018, 9:48 AM Student: Date: Instructor: Alfredo Alvarez Course: Math 0410 Spring 018 Assignment: Math 0410 Homework150bbbbtsiallnew 1. Graph each integer in the list on the same number line.

More information

CpSc 1111 Lab 6 Conditional Statements, Loops, the Math Library, and Random Numbers What s the Point?

CpSc 1111 Lab 6 Conditional Statements, Loops, the Math Library, and Random Numbers What s the Point? CpSc 1111 Lab 6 Conditional Statements, Loops, the Math Library, and Random Numbers What s the Point? Overview For this lab, you will use: one or more of the conditional statements explained below scanf()

More information

Exam 1. CSI 201: Computer Science 1 Fall 2018 Professors: Shaun Ramsey

Exam 1. CSI 201: Computer Science 1 Fall 2018 Professors: Shaun Ramsey Exam 1 CSI 201: Computer Science 1 Fall 2018 Professors: Shaun Ramsey I understand that this exam is closed books and closed notes and is to be completed without a calculator, phone, or other computer.

More information

Elizabethtown Area School District 7th Grade Math Name of Course

Elizabethtown Area School District 7th Grade Math Name of Course 7th Grade Math Name of Course Course Number: N/A Grade Level: 7 Length of Course: full year Total Clock Hours: 150 hours Length of Period: 49 minutes Date Written: 2005-2006 Periods per Week/Cycle: 5/week

More information

5.5 Newton s Approximation Method

5.5 Newton s Approximation Method 498CHAPTER 5. USING DERIVATIVES TO ANALYZE FUNCTIONS; FURTHER APPLICATIONS 4 3 y = x 4 3 f(x) = x cosx y = cosx 3 3 x = cosx x cosx = 0 Figure 5.: Figure showing the existence of a solution of x = cos

More information

Advanced Algorithms and Data Structures

Advanced Algorithms and Data Structures Advanced Algorithms and Data Structures Prof. Tapio Elomaa Course Basics A new 7 credit unit course Replaces OHJ-2156 Analysis of Algorithms We take things a bit further than OHJ-2156 We will assume familiarity

More information

EE 109 Lab 8a Conversion Experience

EE 109 Lab 8a Conversion Experience EE 109 Lab 8a Conversion Experience 1 Introduction In this lab you will write a small program to convert a string of digits representing a number in some other base (between 2 and 10) to decimal. The user

More information

ENCM 369 Winter 2019 Lab 6 for the Week of February 25

ENCM 369 Winter 2019 Lab 6 for the Week of February 25 page of ENCM 369 Winter 29 Lab 6 for the Week of February 25 Steve Norman Department of Electrical & Computer Engineering University of Calgary February 29 Lab instructions and other documents for ENCM

More information

Properties. Comparing and Ordering Rational Numbers Using a Number Line

Properties. Comparing and Ordering Rational Numbers Using a Number Line Chapter 5 Summary Key Terms natural numbers (counting numbers) (5.1) whole numbers (5.1) integers (5.1) closed (5.1) rational numbers (5.1) irrational number (5.2) terminating decimal (5.2) repeating decimal

More information

Algebra 2 Semester 1 (#2221)

Algebra 2 Semester 1 (#2221) Instructional Materials for WCSD Math Common Finals The Instructional Materials are for student and teacher use and are aligned to the 2016-2017 Course Guides for the following course: Algebra 2 Semester

More information

CpSc 1011 Lab 3 Integer Variables, Mathematical Operations, & Redirection

CpSc 1011 Lab 3 Integer Variables, Mathematical Operations, & Redirection CpSc 1011 Lab 3 Integer Variables, Mathematical Operations, & Redirection Overview By the end of the lab, you will be able to: declare variables perform basic arithmetic operations on integer variables

More information

AP Statistics Summer Math Packet

AP Statistics Summer Math Packet NAME: AP Statistics Summer Math Packet PERIOD: Complete all sections of this packet and bring in with you to turn in on the first day of school. ABOUT THIS SUMMER PACKET: In general, AP Statistics includes

More information

SYSTEMS OF NONLINEAR EQUATIONS

SYSTEMS OF NONLINEAR EQUATIONS SYSTEMS OF NONLINEAR EQUATIONS Widely used in the mathematical modeling of real world phenomena. We introduce some numerical methods for their solution. For better intuition, we examine systems of two

More information

P.5 Rational Expressions

P.5 Rational Expressions P.5 Rational Expressions I Domain Domain: Rational expressions : Finding domain a. polynomials: b. Radicals: keep it real! i. sqrt(x-2) x>=2 [2, inf) ii. cubert(x-2) all reals since cube rootscan be positive

More information

Top bar items. Current folder should be shown. Command Window This has the the prompt >>

Top bar items. Current folder should be shown. Command Window This has the the prompt >> MA1710: Week 2 for, if, else, break Getting started in session 2 With the Windows 7 operating system that we have in our Labs start Matlab as you did last week by clicking the mouse pointer on Start (bottom

More information

Math 230 Final Exam December 22, 2015

Math 230 Final Exam December 22, 2015 Math 230 Final Exam December 22, 2015 General Directions. This is an open- book, open- notes, open- computer test. However, you may not communicate with any person, except me, during the test. You have

More information

2 Computation with Floating-Point Numbers

2 Computation with Floating-Point Numbers 2 Computation with Floating-Point Numbers 2.1 Floating-Point Representation The notion of real numbers in mathematics is convenient for hand computations and formula manipulations. However, real numbers

More information

School Year:

School Year: School Year: 2010 2011 1 McDougal Littell CA Math Algebra 1 Pacing Guide Begin First Semester During the first two weeks of school, teachers will work with students on study skills and diagnostic assessments

More information

Com S 227 Assignment Submission HOWTO

Com S 227 Assignment Submission HOWTO Com S 227 Assignment Submission HOWTO This document provides detailed instructions on: 1. How to submit an assignment via Canvas and check it 3. How to examine the contents of a zip file 3. How to create

More information

r the COR d e s 3 A lg e b r a Alabama Pathways

r the COR d e s 3 A lg e b r a Alabama Pathways BUI LT fo COM r the MON COR E Gra 2013 2014 d e s 3 A lg e b r a Alabama Pathways I Grade 3 Operations and Algebraic Thinking Operations and Algebraic Thinking Operations and Algebraic Thinking Number

More information

CS 101 Computer Programming and Utilization. Lecture 5, More Numerical computing (Slides courtesy Prof Ranade)

CS 101 Computer Programming and Utilization. Lecture 5, More Numerical computing (Slides courtesy Prof Ranade) CS 101 Computer Programming and Utilization Dr Deepak B Phatak Subrao Nilekani Chair Professor Department of CSE, Kanwal Rekhi Building IIT Bombay Lecture 5, More Numerical computing (Slides courtesy Prof

More information

In Fig. 3.5 and Fig. 3.7, we include some completely blank lines in the pseudocode for readability. programs into their various phases.

In Fig. 3.5 and Fig. 3.7, we include some completely blank lines in the pseudocode for readability. programs into their various phases. Formulating Algorithms with Top-Down, Stepwise Refinement Case Study 2: Sentinel-Controlled Repetition In Fig. 3.5 and Fig. 3.7, we include some completely blank lines in the pseudocode for readability.

More information

Math 083 Final Exam Practice

Math 083 Final Exam Practice Math 083 Final Exam Practice Name: 1. Simplify the expression. Remember, negative exponents give reciprocals.. Combine the expressions. 3. Write the expression in simplified form. (Assume the variables

More information

Remaining Enhanced Labs

Remaining Enhanced Labs Here are some announcements regarding the end of the semester, and the specifications for the last Enhanced Labs. Don t forget that you need to take the Common Final Examination on Saturday, May 5, from

More information

Chapter 3. More Flow of Control. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Chapter 3. More Flow of Control. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 More Flow of Control Overview 3.1 Using Boolean Expressions 3.2 Multiway Branches 3.3 More about C++ Loop Statements 3.4 Designing Loops Slide 3-3 Flow Of Control Flow of control refers to the

More information

Module 7 Highlights. Mastered Reviewed. Sections ,

Module 7 Highlights. Mastered Reviewed. Sections , Sections 5.3 5.6, 6.1 6.6 Module 7 Highlights Andrea Hendricks Math 0098 Pre-college Algebra Topics Degree & leading coeff. of a univariate polynomial (5.3, Obj. 1) Simplifying a sum/diff. of two univariate

More information

George Mason University ECE 201: Introduction to Signal Analysis Spring 2017

George Mason University ECE 201: Introduction to Signal Analysis Spring 2017 Assigned: January 27, 2017 Due Date: Week of February 6, 2017 George Mason University ECE 201: Introduction to Signal Analysis Spring 2017 Laboratory Project #1 Due Date Your lab report must be submitted

More information

Course Number 432/433 Title Algebra II (A & B) H Grade # of Days 120

Course Number 432/433 Title Algebra II (A & B) H Grade # of Days 120 Whitman-Hanson Regional High School provides all students with a high- quality education in order to develop reflective, concerned citizens and contributing members of the global community. Course Number

More information

Computer Science & Engineering 150A Problem Solving Using Computers

Computer Science & Engineering 150A Problem Solving Using Computers Computer Science & Engineering 150A Problem Solving Using Computers Lecture 03 - Stephen Scott (Adapted from Christopher M. Bourke) 1 / 41 Fall 2009 Chapter 3 3.1 Building Programs from Existing Information

More information

1) Complete problems 1-65 on pages You are encouraged to use the space provided.

1) Complete problems 1-65 on pages You are encouraged to use the space provided. Dear Accelerated Pre-Calculus Student (017-018), I am excited to have you enrolled in our class for next year! We will learn a lot of material and do so in a fairly short amount of time. This class will

More information

CS Homework 11 p. 1. CS Homework 11

CS Homework 11 p. 1. CS Homework 11 CS 111 - Homework 11 p. 1 Deadline 11:59 pm on Monday, May 2, 2016 How to submit Each time you would like to submit your work: CS 111 - Homework 11 If your files are not already on nrs-labs, be sure to

More information

11.3 Function Prototypes

11.3 Function Prototypes 11.3 Function Prototypes A Function Prototype contains the function s return type, name and parameter list Writing the function prototype is declaring the function. float square (float x); In a function

More information

demonstrate an understanding of the exponent rules of multiplication and division, and apply them to simplify expressions Number Sense and Algebra

demonstrate an understanding of the exponent rules of multiplication and division, and apply them to simplify expressions Number Sense and Algebra MPM 1D - Grade Nine Academic Mathematics This guide has been organized in alignment with the 2005 Ontario Mathematics Curriculum. Each of the specific curriculum expectations are cross-referenced to the

More information

CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes

CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes Overview For this lab, you will use: one or more of the conditional statements explained below

More information

Calculus I Review Handout 1.3 Introduction to Calculus - Limits. by Kevin M. Chevalier

Calculus I Review Handout 1.3 Introduction to Calculus - Limits. by Kevin M. Chevalier Calculus I Review Handout 1.3 Introduction to Calculus - Limits by Kevin M. Chevalier We are now going to dive into Calculus I as we take a look at the it process. While precalculus covered more static

More information

Examination Duration Date

Examination Duration Date Hillel Academy High School Grade 9 Mathematics End of Year Study Guide September2013- June 2014 Examination Duration Date The exam consists of 2 papers: Paper 1: Short Response Calculator Paper 2:Structured

More information

Algebra 2 Semester 2 Final Exam Study Outline Semester 2 Final Exam Study Tips and Information

Algebra 2 Semester 2 Final Exam Study Outline Semester 2 Final Exam Study Tips and Information Algebra 2 Semester 2 Final Exam Study Outline 2013 Semester 2 Final Exam Study Tips and Information The final exam is CUMULATIVE and will include all concepts taught from Chapter 1 through Chapter 13.

More information

OVERVIEW DISPLAYING NUMBERS IN SCIENTIFIC NOTATION ENTERING NUMBERS IN SCIENTIFIC NOTATION

OVERVIEW DISPLAYING NUMBERS IN SCIENTIFIC NOTATION ENTERING NUMBERS IN SCIENTIFIC NOTATION OVERVIEW The intent of this material is to provide instruction for the TI-86 graphing calculator that may be used in conjunction with the second edition of Gary Rockswold's College Algebra Through Modeling

More information

D-Optimal Designs. Chapter 888. Introduction. D-Optimal Design Overview

D-Optimal Designs. Chapter 888. Introduction. D-Optimal Design Overview Chapter 888 Introduction This procedure generates D-optimal designs for multi-factor experiments with both quantitative and qualitative factors. The factors can have a mixed number of levels. For example,

More information

Math Released Item Grade 7. Grid Coordinates of a Square VH225469

Math Released Item Grade 7. Grid Coordinates of a Square VH225469 Math Released Item 2018 Grade 7 Grid Coordinates of a Square VH225469 Anchor Set A1 A8 With Annotations Prompt Score Description VH225469 Rubric Part A 2 Student response includes the following 2 Reasoning

More information

Math Glossary Numbers and Arithmetic

Math Glossary Numbers and Arithmetic Math Glossary Numbers and Arithmetic Version 0.1.1 September 1, 200 Next release: On or before September 0, 200. E-mail edu@ezlink.com for the latest version. Copyright 200 by Brad Jolly All Rights Reserved

More information

Mini-Project 1: The Library of Functions and Piecewise-Defined Functions

Mini-Project 1: The Library of Functions and Piecewise-Defined Functions Name Course Days/Start Time Mini-Project 1: The Library of Functions and Piecewise-Defined Functions Part A: The Library of Functions In your previous math class, you learned to graph equations containing

More information

Practical 2: Ray Tracing

Practical 2: Ray Tracing 2017/2018, 4th quarter INFOGR: Graphics Practical 2: Ray Tracing Author: Jacco Bikker The assignment: The purpose of this assignment is to create a small Whitted-style ray tracer. The renderer should be

More information

Name CptS 111, Spring 2018 Programming Assignment #5 Date Name of program Brief description and/or purpose of the program; include sources

Name CptS 111, Spring 2018 Programming Assignment #5 Date Name of program Brief description and/or purpose of the program; include sources CptS 111 PA #5 Due Tuesday, Mar. 20, 2018 for-loops, FIBONACCI, AND A STATISTICS PROGRAM This assignment has two parts and isn t nearly as formidable as it looks (although you shouldn t wait until the

More information

Computer Science & Engineering 150A Problem Solving Using Computers. Chapter 3. Existing Information. Notes. Notes. Notes. Lecture 03 - Functions

Computer Science & Engineering 150A Problem Solving Using Computers. Chapter 3. Existing Information. Notes. Notes. Notes. Lecture 03 - Functions Computer Science & Engineering 150A Problem Solving Using Computers Lecture 03 - Functions Stephen Scott (Adapted from Christopher M. Bourke) Fall 2009 1 / 1 cbourke@cse.unl.edu Chapter 3 3.1 Building

More information

Advanced Algorithms and Data Structures

Advanced Algorithms and Data Structures Advanced Algorithms and Data Structures Prof. Tapio Elomaa tapio.elomaa@tut.fi Course Prerequisites A seven credit unit course Replaced OHJ-2156 Analysis of Algorithms We take things a bit further than

More information

1. Let n be a positive number. a. When we divide a decimal number, n, by 10, how are the numeral and the quotient related?

1. Let n be a positive number. a. When we divide a decimal number, n, by 10, how are the numeral and the quotient related? Black Converting between Fractions and Decimals Unit Number Patterns and Fractions. Let n be a positive number. When we divide a decimal number, n, by 0, how are the numeral and the quotient related?.

More information

Floating-point numbers. Phys 420/580 Lecture 6

Floating-point numbers. Phys 420/580 Lecture 6 Floating-point numbers Phys 420/580 Lecture 6 Random walk CA Activate a single cell at site i = 0 For all subsequent times steps, let the active site wander to i := i ± 1 with equal probability Random

More information

Student Outcomes. Classwork. Discussion (10 minutes)

Student Outcomes. Classwork. Discussion (10 minutes) Student Outcomes Students know the definition of a number raised to a negative exponent. Students simplify and write equivalent expressions that contain negative exponents. Classwork Discussion (10 minutes)

More information

Thursday 14 June 2012 Morning

Thursday 14 June 2012 Morning Thursday 4 June 202 Morning A2 GCE MATHEMATICS 4726 Further Pure Mathematics 2 QUESTION PAPER *47325062* Candidates answer on the Printed Answer Book. OCR supplied materials: Printed Answer Book 4726 List

More information

In this course, you need to use Pearson etext. Go to "Pearson etext and Video Notes".

In this course, you need to use Pearson etext. Go to Pearson etext and Video Notes. **Disclaimer** This syllabus is to be used as a guideline only. The information provided is a summary of topics to be covered in the class. Information contained in this document such as assignments, grading

More information

AE Computer Programming for Aerospace Engineers

AE Computer Programming for Aerospace Engineers AE 030 - Computer Programming for Aerospace Engineers Instructor Information: Credit: Professor Long Lu Long.Lu@sjsu.edu 2 units Class Times & Locations: Section 01 (Lecture): M 16:30-17:20 in CL 226 Section

More information