Numbers, Expressions, Simple Programs

Slides:



Advertisements
Similar presentations
Computer Programming w/ Eng. Applications
Advertisements

Thinking Mathematically
Algebra Factorising and cancelling (a 2 – b 2 ) = (a – b)(a + b) (a  b) 2 = a 2  2ab + b 2.
CSC 160 Computer Programming for Non-Majors Chapter 2: Numbers, Expressions, and Simple Programs Prof. Adam M. Wittenstein
Mathematics of Cryptography Part I: Modular Arithmetic, Congruence,
Algebra: Variables and Expressions variable A variable is a letter or symbol that represents an unknown quantity (a number). ALGEBRA. The branch of mathematics.
BASICS OF COMPUTER APPLICATIONS ASB 102. UNIT 1 Introducing computer system  Number system  What is number system?  Types of number system  Their.
What are the rules of integral exponents?
Properties of Logarithms
Mathematics of Cryptography Part I: Modular Arithmetic, Congruence,
Computer Science: A Structured Programming Approach Using C1 3-7 Sample Programs This section contains several programs that you should study for programming.
Copyright © 2010 Pearson Education, Inc
Lecture for Week Spring.  Numbers can be represented in many ways. We are familiar with the decimal system since it is most widely used in everyday.
Kelsey’s Unit 6 vocab By: Kelsey Mcnally.
Section 3Chapter 8. 1 Copyright © 2012, 2008, 2004 Pearson Education, Inc. Objectives Simplifying Radical Expressions Use the product rule for.
Slide 7- 1 Copyright © 2012 Pearson Education, Inc.
Section 1Chapter 5. 1 Copyright © 2012, 2008, 2004 Pearson Education, Inc. Objectives Integer Exponents and Scientific Notation Use the product.
D-1 University of Washington Computer Programming I Lecture 4: Arithmetic Expressions © 2000 UW CSE.
Homework Assignment #3 J. H. Wang Oct. 29, 2007.
Course contents Chapter 1 - section 1.6 Chapter 2 - all sections Chapter – 4.7, and 4.12 Chapter , Chapter 6 - all sections.
Unit 3 Lesson 2: Rational Expressions
Functional Programming Language 1. A program is: Composition of operations on data Characteristics (in pure form): –Name values, not memory locations.
Analyzing Equations and Inequalities Objectives: - evaluate expressions and formulas using order of operations - understand/use properties & classifications.
Arithmetic OperatorOperationExample +additionx + y -subtractionx - y *multiplicationx * y /divisionx / y Mathematical FormulaC Expressions b 2 – 4acb *
Introduction to Computer Science Lab 1: Numbers and Arithmetic.
Section 02 Numbers, Expressions, Simple Programs Version Prepared by: IT Group Last modified: Apr 04, 2008.
D-1 University of Washington Computer Programming I Lecture 4: Arithmetic Expressions © 2000 UW CSE.
C-1 9/30/99 CSE / ENGR 142 Programming I Arithmetic Expressions © 1999 UW CSE.
MATH 8 CHAPTER 9 TEST REVIEW REAL NUMBERS AND RIGHT TRIANGLES.
Chapter 6 Section 1 - Slide 1 Copyright © 2009 Pearson Education, Inc. Chapter 6 Section 1 - Slide 1 1. Algebra 2. Functions.
Slide Copyright © 2009 Pearson Education, Inc. MM150 Unit 3 Seminar Agenda Order of Operations Linear Equations Formulas Applications of Linear Equations.
Section 03 Programs are functions plus variable definitions Prepared by: IT Group Last modified: Apr 07, 2009.
Absolute value a number’s distance from zero on a number line |-5| = 5 |4| = 4 - |3| = -3 -|-2| = -2.
Comparing and Conditional Expressions Prepared by: IT Group Last modified: Apr 07, 2009 Section 04.
Copyright © 2014, 2010, 2007 Pearson Education, Inc.
Copyright © 2014, 2010, 2007 Pearson Education, Inc.
Copyright © 2014, 2010, 2007 Pearson Education, Inc.
Arithmetic Expressions
Roots, Radicals, and Root Functions
Copyright © 2014, 2010, 2007 Pearson Education, Inc.
College Algebra Chapter 4 Exponential and Logarithmic Functions
Year 6 Block A.
BASIC ELEMENTS OF A COMPUTER PROGRAM
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
5.1 Integer Exponents and Scientific Notation.
Chapter 7 Objectives Define basic terms in algebra: integer, number statement, expression, and coefficient Learn the relationships between positive and.
Rational Exponents Section 6.1
MATHEMATICAL FORMULAS
Arithmetic Operator Operation Example + addition x + y
Algebra Algebra.
Algebra 1 Section 2.2.
Real Number System.
Structure of a C Program
Arithmetic Expressions in C
Copyright © 2014, 2010, 2007 Pearson Education, Inc.
Foundations for Algebra
College Algebra Chapter 4 Exponential and Logarithmic Functions
The area of a rectangle is 2
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
A mathematical phase containing numbers.
Algebra: Variables and Expressions
A mathematical phase containing numbers.
Objective The student will be able to:
Arithmetic Operators Topics Arithmetic Operators Operator Precedence
Knowledge Organiser: Year 7 Spring 1
Algebra 1 Section 2.6.
Division Rules for Exponents
Roots, Radicals, and Root Functions
Using the Distributive Property to Simplify Algebraic Expressions
Presentation transcript:

Numbers, Expressions, Simple Programs Section 02 Numbers, Expressions, Simple Programs Prepared by: IT Group Last modified: Apr 10, 2009 1

Contents The Area of Disk Problem Exercises Theory Part Numbers Expressions Variables Program 2

1. The Area of Disk Problem Develop a program that computes the area of a disk with a given radius.

Solution 4

Step 1: Problem Description 5

Step 2: Function Name 6

Step 3: Test Cases When developing the test cases, we apply the following formula: 3.14 * r2 7

Step 4: Function Template 8

Step 5: Implementation 9

Step 6: Testing 10

2. Exercises 2.1. The Wage Problem 2.2. The Area of Triangle Problem 2.3. The Three Digits Conversion Problem

2.1. The Wage Problem The New Age Inc. company pays all of its employees $12 per hour. A typical employee works between 20 and 65 hours per week. Develop a program that calculates the wage of an employee from the number of hours of work. 12

2.2. The Area of Triangle Problem Develop the program that consumes the length of a triangle's side and the perpendicular height. The program produces the area of the triangle.

2.3. The Three Digits Conversion Problem Develop a program that converts three digits. Starting with the least significant digit, followed by the next most significant one, and so on. The program produces the corresponding number. For example, the expected value of converting 1 2 3 is 321.

3. Theory Part Numbers Expressions Variables Program

3.1. Numbers A positive integer: 5 A negative integer: -5 Fractions: 2/3, 17/3 Real Number: 2.33, 1.56 16

3.2. Expressions Expressions in Scheme Advanced Expressions Nested Expressions

3.2.1. Expressions in Scheme Scheme expression uses the prefix notations:(operation A ... B) Examples: (+ 12 8) (+ 5 5) (+ -5 5)  (+ 5 -5)      (- 5 5)      (* 3 4)       (/ 8 12) 18

3.2.2. Advanced Expressions Scheme provides some advanced mathematical expressions: (sqrt A): computes (A)1/2 = (expt A B): computes AB (remainder A B): computes the remainder of the integer division A/B (quotient A B) : Returns the integer portion of a division … 19

3.2.3. Nested Expressions As in arithmetic or algebra, expressions can be nested: (2 + 2) * (3 – 5) Express above expression in Scheme: (* (+ 2 2) (- 3 5)) 20

3.3. Variables A variable is a placeholder that stands for an unknown quantity. For example, a disk has the approximate area: 3.14 * r2 r is a variable which stands for any positive number. If r = 5 then the area of disk = 3.14 * 52 = 78.5

3.4. Program A program is such a rule that tells us and the computer how to produce data from some other data. Program definition in Scheme: Execute a Program: The naming for a function is very important 22

References How to Design Programs - Section 02 Matthias Felleisen, Robert Bruce Findler, Matthew Flatt,Shriram Krishnamurthi http://htdp.org/2003-09-26/Book/curriculum-Z-H-5.html#node_chap_2 23