Input parameters. Function. An ideal black-box representation of a function

Size: px
Start display at page:

Download "Input parameters. Function. An ideal black-box representation of a function"

Transcription

1 7 Functions 7. Introduction Functions are identifiable pieces of code with a defined interface. They are called from any part of a program and allow large programs to be split into more manageable tasks, each of which can be independently tested. Functions are also useful in building libraries of routines that other programs use. Several standard libraries eist, such as maths and input/output libraries. A function can be thought of as a black bo with a set of inputs and outputs. It processes the inputs in a way dictated by its function and provides some output. In most cases the actual operation of the black bo is invisible to the rest of the program. A modular program consists of a number of black boes working independently of all others, of which each uses variables declared within it (local variables) and any parameters sent to it. Figure 7. illustrates a function represented by an ideal black bo with inputs and outputs, and Figure 7.2 shows a main function calling several sub-functions (or modules). Input parameters Return value Function Function interface Figure 7. An ideal black-bo representation of a function 7.2 Arguments and parameters The data types and names of parameters passed into a function are declared in the function header (its interface) and the actual values sent are referred to as 5 Mastering Pascal

2 arguments. They can be passed either as values (known as passing by value ) or as pointers (known as passing by reference ). Passing by value involves sending a copy of it into the function. It is not possible to change the value of a variable using this method. Variables can only be modified if they are passed by reference (this will be covered in the net chapter). This chapter looks at how parameters pass into a function and how a single value is returned. An argument and a parameter are defined as follows: An argument is the actual value passed to a function. A parameter is the variable defined in the function header. Main program Function Function Function Function Function Function Function Figure 7.2 Hierarchical decomposition of a program 7.3 Pascal functions In Pascal a function returns a single value. It is identified by the function header, which is in the form: FUNCTION function_name(formal_parameter_list) : result_type; where the parameters are passed through the formal_parameter_list and the result type is defined by result_type. Program 7. contains two functions named addition and multiply. In calling the addition function and variables a and b are passed into the parameters c and d, respectively; c and d are local parameters and only eist within addition(). The values of c and d can be changed with no effect Functions 5

3 on the values of a and b. This function returns a value back to the main program by setting a value which is the same name as the function. Program 7. also uses a procedure which, in this case, is similar to a function but does not return any values back to the calling program (procedures will be covered in the net chapter). Program 7. program prog7_(input,output); var a,b,summation,multi:integer; function addition(c,d:integer):integer; addition:=c+d; function multiply(c,d:integer):integer; multiply:=c*d; procedure print_values(c,d,sum,mult:integer); writeln(c,' plus ',d,' is ', sum); writeln(c,' multiplied by ',d, ' is ',mult); a:=5; b:=6; summation:=addition(a,b); multi := multiply(a,b); print_values(a,b,summation,multi); Figure 7.3 shows a simple structure chart of this program. The function addition() is called first; the variables sent are a and b and the return value is put into the variable summation. Net, the multiply() is called; the variables sent are also a and b and the value returned goes into multi. Finally, the function print_values() is called; the values sent are a, b, multi and summation. Program 7. contains functions that return integer data types. It is possible to return any other of Pascal s data types, including real, double and char, by inserting the data type after the function name. A function can have several return points, although it is normally better to have only one return point. This is normally achieved by restructuring the code. An eample of a function with two return values is shown net. In this eample a decision is made as to whether the value passed into the function is positive or negative. If it is greater than or equal to zero it returns the same value, else it returns a negative value (mag=-val). 52 Mastering Pascal

4 main a,b summation a,b multi a,b, summation,multi addition multiply print values Figure 7.3 Basic structure chart for Program 7. program test(input,output); var a:integer; function mag(val:integer):integer; if (val<) then mag:=-val else mag:=val; a:=-5; writeln('mag(a) = ',mag(a)); Program 7.2 contains a function power() which has a return data type of double; the first argument is double and the second is integer. This function uses logarithms to determine the value of raised to the power of n. The formula used is derived net; the ln() function is the natural logarithm and the ep() the eponential function. y = n ln( y) = ln( ) ln( y) = n ln( ) y = ep( n ln( )) n Functions 53

5 Program 7.2 program prog7_2(input,output); var,val:double; n:integer; function power(:double;n:integer):double; power :=ep(n*ln()); writeln('program to determine the result of a value'); writeln('raised to the power of an integer'); writeln('enter to the power of n >>'); readln(,n); val:=power(,n); writeln(,' to power of ',n,' is ',val); 7.4 Local variables Typically variables are required within a function which are not used in the main program. These variables are called local variables and they only eist within the function. A local variable is declared directly after the function header and before the starting keyword. The following eample shows a function called fact which is passed a single integer value (n) and returns a longint data type. It has two local variables, these are val and i. function fact(n:integer):longint; var val,i:longint; (* LOCAL VARIABLES *) val:=; for i:=2 to n do val:=val*i; fact:=val; The outline rules of variable declarations are: Variables that are declared in the main declaration area of the program are known as global variables and they can be accessed by all parts of the program. It is advisable that functions should not use any of the global vari- 54 Mastering Pascal

6 ables directly, but should depend on their values to be passed to them through the function header. Local variables only eist within the function they are declared in, whereas global variables eist throughout the program. A function cannot access another function s local variables. A local variable can have the same name as a global variable. A global variable which has the same name as a local variable will be treated as a different variable. For eample, the global variables i, j and k are declared in the following outline program. Within the function test the local variable i is declared. This will be a different variable to the i global variable. program prog(input,output); var i,j,k: integer; (* GLOBAL VARIABLES *) function test(val:integer):integer; var i:integer; (* LOCAL VARIABLE which is different to *) (* the global variable i *) i:=; k:=5; j:=test(k); 7.5 Eamples This section contains a few sample Pascal programs which use functions Tan function There is no tan function in Pascal; thus to overcome this Pascal Program 7.3 contains a tan function and Test run 7. shows a sample run. Program 7.3 Program prog7_3(input,output); (* Program that uses a function to calculate the *) (* tan of a number *) var answer,number: real; function tan(a:real):real; tan:= sin(a)/cos(a); (* tan is sin over cos *) Functions 55

7 write('enter number >> '); readln(number); answer:=tan(number); writeln('the tan of ',number:8:3,' is ',answer:8:3); Test run 7. Enter number >>.23 The tan of.23 is Centigrade to Fahrenheit conversion Pascal Program 7.4 uses two functions to convert from Fahrenheit to centigrade, and vice versa. Test run 7.2 shows a sample test run. Program 7.4 Program prog7_4(input,output); (* Program that uses a function to convert Fahrenheit to centigrade*) var fahrenheit,centigrade:real; function convert_to_centigrade(f:real ):real; convert_to_centigrade:=5/9* (f-32); function convert_to_fahrenheit(c:real ) :real; convert_to_fahrenheit:=9/5*c+32; write('enter value in Fahrenheit >> '); readln(fahrenheit); centigrade:=convert_to_centigrade(fahrenheit); writeln(fahrenheit:6:3, deg F is ', centigrade:6:3,' deg C'); write('enter value in centigrade'); readln(centigrade); Fahrenheit:=convert_to_fahrenheit(centigrade); writeln(centigrade:6:3,' deg C is ',Fahrenheit:6:3,' deg F'); Test run 7.2 Enter value in Fahrenheit >> 2 2. deg F is -. deg C Enter value in centigrade >> 6 6. deg C is 4. deg F 56 Mastering Pascal

8 Pascal Program 7.5 uses the two functions developed in the previous programs to display a table of values from C to C in steps of C. Test run 7.3 shows a sample run. Program 7.5 Program prog7_5(input,output); (* Program that uses a function to convert centigrade to *) (* Fahrenheit. Centigrade goes from to in steps of. *) var fahrenheit,centigrade:real; i: integer; function convert_to_fahrenheit(c:real ):real; convert_to_fahrenheit:=9/5*c+32; writeln('centigrade Fahrenheit'); for i:= to do centigrade:=*i; fahrenheit:=convert_to_fahrenheit(centigrade); writeln(centigrade:8:3,fahrenheit:8:3); Test run 7.3 Centigrade Fahrenheit Combinational logic In this eample, the following Boolean equation is processed to determine its truth table. Z = ( A + B + ( A. C)). C Figure 7.4 gives a schematic representation of this Boolean function. The four nodes numbered on this schematic are: Functions 57

9 () A + B (2) A. C (3) A + B + ( A. C) (4) ( A + B + ( A. C)). C A B () (3) C (2) (4) Z Figure 7.4 Schematic representation of the function Z = ( A + B + ( A. C)). C Table 7. gives a truth table showing the logical level at each point in the schematic. This table is necessary to check the program results against epected results. Table 7.2 gives the resulting truth table. Table 7. Truth table A B C A + B () A. C (2) A B A C + + (. ) (3) ( A + B + ( A. C)). C (4) Table 7.2 Truth table A B C Z 58 Mastering Pascal

10 Pascal Program 7.6 shows how this Boolean equation is simulated. The permutations of the truth table input variables (that is,,,,,..., ) are generated using 3 nested for loops. The inner loop toggles C from a to a, the net loop toggles B and the outer loop toggles A. The Boolean functions use the logical operators and and or. As Pascal has reserved keywords for AND, OR and NOT the function names have been changed to reflect the number of inputs they have, such as OR3 for a 3-input OR gate and AND2 for a 2-input AND gate. Test run 7.4 shows a sample run of the program. Notice that the results are identical to the truth table generated by analyzing the schematic (apart from / indicated with a FALSE/TRUE). Test run 7.4 A B C Result *************************** FALSE FALSE FALSE TRUE FALSE FALSE TRUE FALSE FALSE TRUE FALSE TRUE FALSE TRUE TRUE TRUE TRUE FALSE FALSE TRUE TRUE FALSE TRUE FALSE TRUE TRUE FALSE TRUE TRUE TRUE TRUE FALSE Program 7.6 program prog7_6(input,output); var a,b,c,z:boolean; function NOR2(, y:boolean):boolean; if ( or y ) then nor2:=false else nor2:=true; function OR2(, y:boolean):boolean; if ( or y) then or2:=true else or2:=false; function AND2(, y:boolean):boolean; if ( and y) then and2:=true else and2:=false; function NAND2(, y:boolean):boolean; if ( and y ) then nand2:=false else nand2:=true; Functions 59

11 writeln(' A B C Result'); writeln(' *****************************'); for a:=false to TRUE do for b:=false to TRUE do for c:=false to TRUE do z:=nand2(or2(nor2(a,b),and2(a,c)),c); writeln(a:6,b:6,c:6,z:6); Sine of a value The sine of a value can be determined, from first principles, using the formula: 3 sin( ) = 3! + 5 5! 7 7! + 9 9! K where n! = n ( n ) ( n 2) K 2 and the value of is in radians. Pascal Program 7.7 gives a Pascal program which has a function called sine(). This function calculates the sine of a value using the formula given above. It uses a repeat until loop which calculates each term of the equation and adds it to a running total for the loop. The loop continues until the calculated term is less than 6. The program also includes the following functions: fact(n) which is used to determine the factorial of an integer value, the result is a longint as it may be a large value. pow(,n) which is used to determine the value of to the power of n. to_radians() which is used to convert the value of into radians (by multiplying by π and dividing by 8). Test run 7.5 gives a sample run of this program. It can be seen that the function sine() returns the same value as the Pascal sin() function. Test run 7.5 Enter value (in degrees) >> 23 Sine is.39 Sin is.39 6 Mastering Pascal

12 Program 7.7 program prog7_7(input,output); (* Program to determine the sine of a value from first principles *) var invalue:real; function pow(:real;n:real):real; pow:=ep(n*ln()); function fact(n:integer):longint; var val,i:longint; val:=; for i:=2 to n do val:=val*i; fact:=val; function sine(:real):real; var n,sign:integer; val,term:real; sign:=; val:=; n:=3; repeat term:=pow(,n)/fact(n); n:=n+2; sign:=-sign; val:=val+sign*term; until (term<e-6); (* repeat until term is less than e-6 *) sine:=val; function to_radians(val:real):real; to_radians:=pi*val/8; writeln('enter value (in degrees) >>'); readln(invalue); invalue:=to_radians(invalue); writeln('sine is ',sine(invalue):8:3); writeln('sin is ',sin(invalue):8:3); Functions 6

13 7.6 Eercises 7.6. Write a program which determines the magnitude of an entered value. The program should use a function to determine this Write a program with a function which is passed an arithmetic operator character and two real values. The function will then return the result of the operator on the two values. Program 7.8 shows an outline of the program. Program 7.8 program prog7_8(input,output); var operator:char; value,value2,result:real; function math_function(ch:char;val,val2:real):real; var result:real; case ch of '+': result:=val+val2; '-': result:=val-val2; (* *** Add etra code here *** *) math_function:=result; writeln('enter operator >>'); readln(operator); writeln('enter two values >>'); readln(value,value2); result:=math_function(operator,value,value2); writeln('result is ',result); Write a program with separate functions which determine the gradient of a straight line (m) and the point at which a straight line cuts the y-ais (c). The entered parameters are two points on the line, that is, (, y ) and ( 2, y 2 ). From this program complete Table 7.3 (the first row has already been completed). Table 7.3 Straight line calculations y 2 y 2 m c Mastering Pascal

14 Formulas to calculate these values are: m y y 2 = c = y m Write a program which determines the magnitude and angle of a comple number (in the form +iy, or +jy). The program should use functions to determine each of the values. Complete Table 7.4 using the program (the first row has already been completed), where: 2 2 = y angle = tan mag + y Table 7.4 Comple number calculation y Mag. Angle( ) Referring to Program 7.7, write a function for a cosine function. It can be calculated, from first principles, with: cos( ) = 2 2! + 4 4! 6 6! + 8 8! K The error in the function should be less than Using the functions developed in Eercise and Program 7.7 and the standard sine and cosine library functions, write a program which determines the error between the standard library functions and the developed functions. From this, complete Table 7.5. Table 7.5 Sine and cosine results Value Standard cosine function Developed cosine function Standard sine function Developed sine function Write a mathematical function which determines the eponential of a value using the first principles formula: Functions 63

15 e = + +! 2 2! + 3 3! + 4 4! +K Compare the result with the standard ep() library function Write Boolean logic functions for the following four digital gates: AND3(A,B,C) OR3(A,B,C) NAND3(A,B,C) NOR3(A,B,C) Write a program which has a function which will only return a real value when the entered value is within a specified range. An eample call to this function (which, in this case, is named get_real) is:. inval:=get_real(,); This will only return a value from the function when the entered value is between and. A sample run follows. Test run 7.6 Enter a value > - INVALID INPUT PLEASE RE-ENTER Enter a value > 6 Success. Bye. 64 Mastering Pascal

Chapter 3 - Functions

Chapter 3 - Functions Chapter 3 - Functions 1 Outline 3.1 Introduction 3.2 Program Components in C++ 3.3 Math Library Functions 3.4 Functions 3.5 Function Definitions 3.6 Function Prototypes 3.7 Header Files 3.8 Random Number

More information

Methods CSC 121 Fall 2016 Howard Rosenthal

Methods CSC 121 Fall 2016 Howard Rosenthal Methods CSC 121 Fall 2016 Howard Rosenthal Lesson Goals Understand what a method is in Java Understand Java s Math Class and how to use it Learn the syntax of method construction Learn both void methods

More information

Methods CSC 121 Spring 2017 Howard Rosenthal

Methods CSC 121 Spring 2017 Howard Rosenthal Methods CSC 121 Spring 2017 Howard Rosenthal Lesson Goals Understand what a method is in Java Understand Java s Math Class and how to use it Learn the syntax of method construction Learn both void methods

More information

Built-in Types of Data

Built-in Types of Data Built-in Types of Data Types A data type is set of values and a set of operations defined on those values Python supports several built-in data types: int (for integers), float (for floating-point numbers),

More information

Structured Programming. Dr. Mohamed Khedr Lecture 9

Structured Programming. Dr. Mohamed Khedr Lecture 9 Structured Programming Dr. Mohamed Khedr http://webmail.aast.edu/~khedr 1 Two Types of Loops count controlled loops repeat a specified number of times event-controlled loops some condition within the loop

More information

Limits and Derivatives (Review of Math 249 or 251)

Limits and Derivatives (Review of Math 249 or 251) Chapter 3 Limits and Derivatives (Review of Math 249 or 251) 3.1 Overview This is the first of two chapters reviewing material from calculus; its and derivatives are discussed in this chapter, and integrals

More information

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 4

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 4 BIL 104E Introduction to Scientific and Engineering Computing Lecture 4 Introduction Divide and Conquer Construct a program from smaller pieces or components These smaller pieces are called modules Functions

More information

Proving Trigonometric Identities

Proving Trigonometric Identities MHF 4UI Unit 7 Day Proving Trigonometric Identities An identity is an epression which is true for all values in the domain. Reciprocal Identities csc θ sin θ sec θ cos θ cot θ tan θ Quotient Identities

More information

Functions. Systems Programming Concepts

Functions. Systems Programming Concepts Functions Systems Programming Concepts Functions Simple Function Example Function Prototype and Declaration Math Library Functions Function Definition Header Files Random Number Generator Call by Value

More information

u u 1 u (c) Distributive property of multiplication over subtraction

u u 1 u (c) Distributive property of multiplication over subtraction ADDITIONAL ANSWERS 89 Additional Answers Eercises P.. ; All real numbers less than or equal to 4 0 4 6. ; All real numbers greater than or equal to and less than 4 0 4 6 7. ; All real numbers less than

More information

Edexcel Core Mathematics 4 Integration

Edexcel Core Mathematics 4 Integration Edecel Core Mathematics 4 Integration Edited by: K V Kumaran kumarmaths.weebly.com Integration It might appear to be a bit obvious but you must remember all of your C work on differentiation if you are

More information

You can take the arccos of both sides to get θ by itself.

You can take the arccos of both sides to get θ by itself. .7 SOLVING TRIG EQUATIONS Example on p. 8 How do you solve cos ½ for? You can tae the arccos of both sides to get by itself. cos - (cos ) cos - ( ½) / However, arccos only gives us an answer between 0

More information

Section 1.4 Limits involving infinity

Section 1.4 Limits involving infinity Section. Limits involving infinit (/3/08) Overview: In later chapters we will need notation and terminolog to describe the behavior of functions in cases where the variable or the value of the function

More information

f(x) lim does not exist.

f(x) lim does not exist. Indeterminate Forms and L Hopital s Rule When we computed its of quotients, i.e. its of the form f() a g(), we came across several different things that could happen: f(). a g() = f(a) g(a) when g(). a

More information

EE292: Fundamentals of ECE

EE292: Fundamentals of ECE EE292: Fundamentals of ECE Fall 2012 TTh 10:00-11:15 SEB 1242 Lecture 22 121115 http://www.ee.unlv.edu/~b1morris/ee292/ 2 Outline Review Binary Number Representation Binary Arithmetic Combinatorial Logic

More information

(Type your answer in radians. Round to the nearest hundredth as needed.)

(Type your answer in radians. Round to the nearest hundredth as needed.) 1. Find the exact value of the following expression within the interval (Simplify your answer. Type an exact answer, using as needed. Use integers or fractions for any numbers in the expression. Type N

More information

Function Example. Function Definition. C Programming. Syntax. A small program(subroutine) that performs a particular task. Modular programming design

Function Example. Function Definition. C Programming. Syntax. A small program(subroutine) that performs a particular task. Modular programming design What is a Function? C Programming Lecture 8-1 : Function (Basic) A small program(subroutine) that performs a particular task Input : parameter / argument Perform what? : function body Output t : return

More information

Sharp EL-9900 Graphing Calculator

Sharp EL-9900 Graphing Calculator Sharp EL-9900 Graphing Calculator Basic Keyboard Activities General Mathematics Algebra Programming Advanced Keyboard Activities Algebra Calculus Statistics Trigonometry Programming Sharp EL-9900 Graphing

More information

Introduction to Programming

Introduction to Programming Introduction to Programming session 9 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2010 These slides are created using Deitel s slides Sahrif University of Technology Outlines

More information

Dr M Kasim A Jalil. Faculty of Mechanical Engineering UTM (source: Deitel Associates & Pearson)

Dr M Kasim A Jalil. Faculty of Mechanical Engineering UTM (source: Deitel Associates & Pearson) Lecture 9 Functions Dr M Kasim A Jalil Faculty of Mechanical Engineering UTM (source: Deitel Associates & Pearson) Objectives In this chapter, you will learn: To understand how to construct programs modularly

More information

Lecture 2 FORTRAN Basics. Lubna Ahmed

Lecture 2 FORTRAN Basics. Lubna Ahmed Lecture 2 FORTRAN Basics Lubna Ahmed 1 Fortran basics Data types Constants Variables Identifiers Arithmetic expression Intrinsic functions Input-output 2 Program layout PROGRAM program name IMPLICIT NONE

More information

Let us start with a quick revision of algebra and how to work with variables. Now let us look at the simpler topic, namely Substitution.

Let us start with a quick revision of algebra and how to work with variables. Now let us look at the simpler topic, namely Substitution. Section F Algebra & Equations Objective In this section, we will be dealing with solving equations for the variable involved, manipulating formulae to get one variable as the subject of the formula and

More information

Programming Fundamentals for Engineers Functions. Muntaser Abulafi Yacoub Sabatin Omar Qaraeen. Modular programming.

Programming Fundamentals for Engineers Functions. Muntaser Abulafi Yacoub Sabatin Omar Qaraeen. Modular programming. Programming Fundamentals for Engineers - 0702113 7. Functions Muntaser Abulafi Yacoub Sabatin Omar Qaraeen 1 Modular programming Your program main() function Calls AnotherFunction1() Returns the results

More information

Lesson #3. Variables, Operators, and Expressions. 3. Variables, Operators and Expressions - Copyright Denis Hamelin - Ryerson University

Lesson #3. Variables, Operators, and Expressions. 3. Variables, Operators and Expressions - Copyright Denis Hamelin - Ryerson University Lesson #3 Variables, Operators, and Expressions Variables We already know the three main types of variables in C: int, char, and double. There is also the float type which is similar to double with only

More information

Basic types and definitions. Chapter 3 of Thompson

Basic types and definitions. Chapter 3 of Thompson Basic types and definitions Chapter 3 of Thompson Booleans [named after logician George Boole] Boolean values True and False are the result of tests are two numbers equal is one smaller than the other

More information

What did we talk about last time? Examples switch statements

What did we talk about last time? Examples switch statements Week 4 - Friday What did we talk about last time? Examples switch statements History of computers Hardware Software development Basic Java syntax Output with System.out.print() Mechanical Calculation

More information

Honors Precalculus: Solving equations and inequalities graphically and algebraically. Page 1

Honors Precalculus: Solving equations and inequalities graphically and algebraically. Page 1 Solving equations and inequalities graphically and algebraically 1. Plot points on the Cartesian coordinate plane. P.1 2. Represent data graphically using scatter plots, bar graphs, & line graphs. P.1

More information

Trigonometric Functions of Any Angle

Trigonometric Functions of Any Angle Trigonometric Functions of Any Angle MATH 160, Precalculus J. Robert Buchanan Department of Mathematics Fall 2011 Objectives In this lesson we will learn to: evaluate trigonometric functions of any angle,

More information

2.2 Limit of a Function and Limit Laws

2.2 Limit of a Function and Limit Laws Limit of a Function and Limit Laws Section Notes Page Let s look at the graph y What is y()? That s right, its undefined, but what if we wanted to find the y value the graph is approaching as we get close

More information

1. Let be a point on the terminal side of θ. Find the 6 trig functions of θ. (Answers need not be rationalized). b. P 1,3. ( ) c. P 10, 6.

1. Let be a point on the terminal side of θ. Find the 6 trig functions of θ. (Answers need not be rationalized). b. P 1,3. ( ) c. P 10, 6. Q. Right Angle Trigonometry Trigonometry is an integral part of AP calculus. Students must know the basic trig function definitions in terms of opposite, adjacent and hypotenuse as well as the definitions

More information

Making Decisions In Pascal

Making Decisions In Pascal Making Decisions In Pascal In this section of notes you will learn how to have your Pascal programs choose between alternative courses of action High Level View Of Decision Making For The Computer??? True

More information

A/L 2011_revision. PASCAL PROGRAMMING

A/L 2011_revision. PASCAL PROGRAMMING Pascal is a high level programming language developed by Niklaus Wirth in 1970 based on the ALGOL programming language. It was named in honor of the French mathematician and philosopher Blaise Pascal.

More information

VBScript: Math Functions

VBScript: Math Functions C h a p t e r 3 VBScript: Math Functions In this chapter, you will learn how to use the following VBScript functions to World Class standards: 1. Writing Math Equations in VBScripts 2. Beginning a New

More information

Integrating ICT into mathematics at KS4&5

Integrating ICT into mathematics at KS4&5 Integrating ICT into mathematics at KS4&5 Tom Button tom.button@mei.org.uk www.mei.org.uk/ict/ This session will detail the was in which ICT can currentl be used in the teaching and learning of Mathematics

More information

ME1107 Computing Y Yan.

ME1107 Computing Y Yan. ME1107 Computing 1 2008-2009 Y Yan http://www.staff.city.ac.uk/~ensyy About Fortran Fortran Formula Translation High level computer language Basic, Fortran, C, C++, Java, C#, (Matlab) What do we learn?

More information

Chapter 3 Part 2 Combinational Logic Design

Chapter 3 Part 2 Combinational Logic Design University of Wisconsin - Madison ECE/Comp Sci 352 Digital Systems Fundamentals Kewal K. Saluja and Yu Hen Hu Spring 2002 Chapter 3 Part 2 Combinational Logic Design Originals by: Charles R. Kime and Tom

More information

Arithmetic and Logic Blocks

Arithmetic and Logic Blocks Arithmetic and Logic Blocks The Addition Block The block performs addition and subtractions on its inputs. This block can add or subtract scalar, vector, or matrix inputs. We can specify the operation

More information

SLOPE A MEASURE OF STEEPNESS through 7.1.5

SLOPE A MEASURE OF STEEPNESS through 7.1.5 SLOPE A MEASURE OF STEEPNESS 7.1. through 7.1.5 Students have used the equation = m + b throughout this course to graph lines and describe patterns. When the equation is written in -form, the m is the

More information

Trigonometry Review Day 1

Trigonometry Review Day 1 Name Trigonometry Review Day 1 Algebra II Rotations and Angle Terminology II Terminal y I Positive angles rotate in a counterclockwise direction. Reference Ray Negative angles rotate in a clockwise direction.

More information

Test #2 October 8, 2015

Test #2 October 8, 2015 CPSC 1040 Name: Test #2 October 8, 2015 Closed notes, closed laptop, calculators OK. Please use a pencil. 100 points, 5 point bonus. Maximum score 105. Weight of each section in parentheses. If you need

More information

SNAP Centre Workshop. Introduction to Trigonometry

SNAP Centre Workshop. Introduction to Trigonometry SNAP Centre Workshop Introduction to Trigonometry 62 Right Triangle Review A right triangle is any triangle that contains a 90 degree angle. There are six pieces of information we can know about a given

More information

correlated to the Michigan High School Mathematics Content Expectations

correlated to the Michigan High School Mathematics Content Expectations correlated to the Michigan High School Mathematics Content Expectations McDougal Littell Algebra 1 Geometry Algebra 2 2007 correlated to the STRAND 1: QUANTITATIVE LITERACY AND LOGIC (L) STANDARD L1: REASONING

More information

1001ICT Introduction To Programming Lecture Notes

1001ICT Introduction To Programming Lecture Notes 1001ICT Introduction To Programming Lecture Notes School of Information and Communication Technology Griffith University Semester 1, 2015 1 M Environment console M.1 Purpose This environment supports programming

More information

Math for Geometric Optics

Math for Geometric Optics Algebra skills Math for Geometric Optics general rules some common types of equations units problems with several variables (substitution) Geometry basics Trigonometry Pythagorean theorem definitions,

More information

Methods (Deitel chapter 6)

Methods (Deitel chapter 6) Methods (Deitel chapter 6) 1 Plan 2 Introduction Program Modules in Java Math-Class Methods Method Declarations Argument Promotion Java API Packages Random-Number Generation Scope of Declarations Methods

More information

Section 4.2 Graphs of Exponential Functions

Section 4.2 Graphs of Exponential Functions 238 Chapter 4 Section 4.2 Graphs of Eponential Functions Like with linear functions, the graph of an eponential function is determined by the values for the parameters in the function s formula. To get

More information

ENGINEERING 1020 Introduction to Computer Programming M A Y 2 6, R E Z A S H A H I D I

ENGINEERING 1020 Introduction to Computer Programming M A Y 2 6, R E Z A S H A H I D I ENGINEERING 1020 Introduction to Computer Programming M A Y 2 6, 2 0 1 0 R E Z A S H A H I D I Today s class Constants Assignment statement Parameters and calling functions Expressions Mixed precision

More information

The Fortran Basics. Handout Two February 10, 2006

The Fortran Basics. Handout Two February 10, 2006 The Fortran Basics Handout Two February 10, 2006 A Fortran program consists of a sequential list of Fortran statements and constructs. A statement can be seen a continuous line of code, like b=a*a*a or

More information

Practice problems Set 2

Practice problems Set 2 Practice problems Set 2 1) Write a program to obtain transpose of a 4 x 4 matrix. The transpose of matrix is obtained by exchanging the elements of each row with the elements of the corresponding column.

More information

TABLE OF CONTENTS CHAPTER 1 LIMIT AND CONTINUITY... 26

TABLE OF CONTENTS CHAPTER 1 LIMIT AND CONTINUITY... 26 TABLE OF CONTENTS CHAPTER LIMIT AND CONTINUITY... LECTURE 0- BASIC ALGEBRAIC EXPRESSIONS AND SOLVING EQUATIONS... LECTURE 0- INTRODUCTION TO FUNCTIONS... 9 LECTURE 0- EXPONENTIAL AND LOGARITHMIC FUNCTIONS...

More information

Graphing Calculator Scientific Calculator Version 2.0

Graphing Calculator Scientific Calculator Version 2.0 Graphing Calculator Scientific Calculator Version 2.0 www.infinitysw.com/ets March 14, 2017 1 Table of Contents Table of Contents 1 Overview 3 2 Navigation 4 3 Using the Calculator 5 Display 5 Performing

More information

Names and Functions. Chapter 2

Names and Functions. Chapter 2 Chapter 2 Names and Functions So far we have built only tiny toy programs. To build bigger ones, we need to be able to name things so as to refer to them later. We also need to write expressions whose

More information

4038 ADDITIONAL MATHEMATICS TOPIC 2: GEOMETRY AND TRIGONOMETRY SUB-TOPIC 2.2 COORDINATE GEOMETRY IN TWO DIMENSIONS

4038 ADDITIONAL MATHEMATICS TOPIC 2: GEOMETRY AND TRIGONOMETRY SUB-TOPIC 2.2 COORDINATE GEOMETRY IN TWO DIMENSIONS 4038 ADDITIONAL MATHEMATICS TOPIC : GEOMETRY AND TRIGONOMETRY SUB-TOPIC. COORDINATE GEOMETRY IN TWO DIMENSIONS CONTENT OUTLINE. Condition for two lines to be parallel or perpendicular. Mid-point of line

More information

Introduction to Computers II Lecture 4. Dr Ali Ziya Alkar Dr Mehmet Demirer

Introduction to Computers II Lecture 4. Dr Ali Ziya Alkar Dr Mehmet Demirer Introduction to Computers II Lecture 4 Dr Ali Ziya Alkar Dr Mehmet Demirer 1 Contents: Utilizing the existing information Top-down design Start with the broadest statement of the problem Works down to

More information

Blue Pelican Calculator Appendices

Blue Pelican Calculator Appendices Blue Pelican Calculator Appendices Version 1.01 Copyright 2009-2011 by Charles E. Cook; Refugio, Tx (All rights reserved) Graphing Calculator Appendices Appendix A: Special marking of graphed functions

More information

5. Selection: If and Switch Controls

5. Selection: If and Switch Controls Computer Science I CS 135 5. Selection: If and Switch Controls René Doursat Department of Computer Science & Engineering University of Nevada, Reno Fall 2005 Computer Science I CS 135 0. Course Presentation

More information

10 Using the PCFL Editor In this chapter

10 Using the PCFL Editor In this chapter 10 Using the PCFL Editor In this chapter Introduction to the PCFL editor 260 Editing PCFL registers 261 Customizing the PCFL configuration file 272 ProWORX NxT User s Guide Introduction to the PCFL editor

More information

1. Use the Trapezium Rule with five ordinates to find an approximate value for the integral

1. Use the Trapezium Rule with five ordinates to find an approximate value for the integral 1. Use the Trapezium Rule with five ordinates to find an approximate value for the integral Show your working and give your answer correct to three decimal places. 2 2.5 3 3.5 4 When When When When When

More information

Math 231E, Lecture 34. Polar Coordinates and Polar Parametric Equations

Math 231E, Lecture 34. Polar Coordinates and Polar Parametric Equations Math 231E, Lecture 34. Polar Coordinates and Polar Parametric Equations 1 Definition of polar coordinates Let us first recall the definition of Cartesian coordinates: to each point in the plane we can

More information

Module 10A Lecture - 20 What is a function? Why use functions Example: power (base, n)

Module 10A Lecture - 20 What is a function? Why use functions Example: power (base, n) Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute of Technology, Madras Module 10A Lecture - 20 What is a function?

More information

CSI33 Data Structures

CSI33 Data Structures Outline Department of Mathematics and Computer Science Bronx Community College October 24, 2018 Outline Outline 1 Chapter 8: A C++ Introduction For Python Programmers Expressions and Operator Precedence

More information

C1M0 Introduction to Maple Assignment Format C1M1 C1M1 Midn John Doe Section 1234 Beginning Maple Syntax any

C1M0 Introduction to Maple Assignment Format C1M1 C1M1 Midn John Doe Section 1234 Beginning Maple Syntax any CM0 Introduction to Maple Our discussion will focus on Maple 6, which was developed by Waterloo Maple Inc. in Waterloo, Ontario, Canada. Quoting from the Maple 6 Learning Guide, Maple is a Symbolic Computation

More information

The Straight Line. m is undefined. Use. Show that mab

The Straight Line. m is undefined. Use. Show that mab The Straight Line What is the gradient of a horizontal line? What is the equation of a horizontal line? So the equation of the x-axis is? What is the gradient of a vertical line? What is the equation of

More information

AN INTRODUCTION TO MATLAB

AN INTRODUCTION TO MATLAB AN INTRODUCTION TO MATLAB 1 Introduction MATLAB is a powerful mathematical tool used for a number of engineering applications such as communication engineering, digital signal processing, control engineering,

More information

Documentation for LISP in BASIC

Documentation for LISP in BASIC Documentation for LISP in BASIC The software and the documentation are both Copyright 2008 Arthur Nunes-Harwitt LISP in BASIC is a LISP interpreter for a Scheme-like dialect of LISP, which happens to have

More information

Dr Richard Greenaway

Dr Richard Greenaway SCHOOL OF PHYSICS, ASTRONOMY & MATHEMATICS 4PAM1008 MATLAB 3 Creating, Organising & Processing Data Dr Richard Greenaway 3 Creating, Organising & Processing Data In this Workshop the matrix type is introduced

More information

Math : Differentiation

Math : Differentiation EP-Program - Strisuksa School - Roi-et Math : Differentiation Dr.Wattana Toutip - Department of Mathematics Khon Kaen University 00 :Wattana Toutip wattou@kku.ac.th http://home.kku.ac.th/wattou. Differentiation

More information

For more information, see the Math Notes box in Lesson of the Core Connections, Course 1 text.

For more information, see the Math Notes box in Lesson of the Core Connections, Course 1 text. Number TYPES OF NUMBERS When two or more integers are multiplied together, each number is a factor of the product. Nonnegative integers that have eactly two factors, namely, one and itself, are called

More information

Labview. Masood Ejaz

Labview. Masood Ejaz Labview A Tutorial By Masood Ejaz Note: This tutorial is a work in progress and written specially for CET 3464 Software Applications in Engineering Technology, a course offered as part of BSECET program

More information

Unit 6 Introduction to Trigonometry The Unit Circle (Unit 6.3)

Unit 6 Introduction to Trigonometry The Unit Circle (Unit 6.3) Unit Introduction to Trigonometr The Unit Circle Unit.) William Bill) Finch Mathematics Department Denton High School Introduction Trig Functions Circle Quadrental Angles Other Angles Unit Circle Periodic

More information

Calculus I (part 1): Limits and Continuity (by Evan Dummit, 2016, v. 2.01)

Calculus I (part 1): Limits and Continuity (by Evan Dummit, 2016, v. 2.01) Calculus I (part ): Limits and Continuity (by Evan Dummit, 206, v. 2.0) Contents Limits and Continuity. Limits (Informally)...............................................2 Limits and the Limit Laws..........................................

More information

Methods (Deitel chapter 6)

Methods (Deitel chapter 6) 1 Plan 2 Methods (Deitel chapter ) Introduction Program Modules in Java Math-Class Methods Method Declarations Argument Promotion Java API Packages Random-Number Generation Scope of Declarations Methods

More information

9691 COMPUTING. 9691/22 Paper 2 (Written Paper), maximum raw mark 75

9691 COMPUTING. 9691/22 Paper 2 (Written Paper), maximum raw mark 75 CAMBRIDGE INTERNATIONAL EXAMINATIONS Cambridge International Advanced Subsidiary and Advanced Level MARK SCHEME for the May/June 2015 series 9691 COMPUTING 9691/22 Paper 2 (Written Paper), maximum raw

More information

10.7. Polar Coordinates. Introduction. What you should learn. Why you should learn it. Example 1. Plotting Points on the Polar Coordinate System

10.7. Polar Coordinates. Introduction. What you should learn. Why you should learn it. Example 1. Plotting Points on the Polar Coordinate System _7.qxd /8/5 9: AM Page 779 Section.7 Polar Coordinates 779.7 Polar Coordinates What ou should learn Plot points on the polar coordinate sstem. Convert points from rectangular to polar form and vice versa.

More information

Functions. Lecture 6 COP 3014 Spring February 11, 2018

Functions. Lecture 6 COP 3014 Spring February 11, 2018 Functions Lecture 6 COP 3014 Spring 2018 February 11, 2018 Functions A function is a reusable portion of a program, sometimes called a procedure or subroutine. Like a mini-program (or subprogram) in its

More information

Introduction to Visual Basic and Visual C++ Arithmetic Expression. Arithmetic Expression. Using Arithmetic Expression. Lesson 4.

Introduction to Visual Basic and Visual C++ Arithmetic Expression. Arithmetic Expression. Using Arithmetic Expression. Lesson 4. Introduction to Visual Basic and Visual C++ Arithmetic Expression Lesson 4 Calculation I154-1-A A @ Peter Lo 2010 1 I154-1-A A @ Peter Lo 2010 2 Arithmetic Expression Using Arithmetic Expression Calculations

More information

Math 144 Activity #4 Connecting the unit circle to the graphs of the trig functions

Math 144 Activity #4 Connecting the unit circle to the graphs of the trig functions 144 p 1 Math 144 Activity #4 Connecting the unit circle to the graphs of the trig functions Graphing the sine function We are going to begin this activity with graphing the sine function ( y = sin x).

More information

TI-89 Clinic. Let s first set up our calculators so that we re all working in the same mode.

TI-89 Clinic. Let s first set up our calculators so that we re all working in the same mode. TI-89 Clinic Preliminaries Let s first set up our calculators so that we re all working in the same mode. From the home screen, select F6 new problem. Hit enter to eecute that command. This erases previous

More information

COMP combinational logic 1 Jan. 18, 2016

COMP combinational logic 1 Jan. 18, 2016 In lectures 1 and 2, we looked at representations of numbers. For the case of integers, we saw that we could perform addition of two numbers using a binary representation and using the same algorithm that

More information

LIGHT: Two-slit Interference

LIGHT: Two-slit Interference LIGHT: Two-slit Interference Objective: To study interference of light waves and verify the wave nature of light. Apparatus: Two red lasers (wavelength, λ = 633 nm); two orange lasers (λ = 612 nm); two

More information

Methods CSC 121 Fall 2014 Howard Rosenthal

Methods CSC 121 Fall 2014 Howard Rosenthal Methods CSC 121 Fall 2014 Howard Rosenthal Lesson Goals Understand what a method is in Java Understand Java s Math Class Learn the syntax of method construction Learn both void methods and methods that

More information

Subject: Computer Science

Subject: Computer Science Subject: Computer Science Topic: Data Types, Variables & Operators 1 Write a program to print HELLO WORLD on screen. 2 Write a program to display output using a single cout statement. 3 Write a program

More information

Beginning Programming (Pascal) Lecture 75. Figure 1. type-declarations. simple-type. pointer-type. array-type. file-type. set-type.

Beginning Programming (Pascal) Lecture 75. Figure 1. type-declarations. simple-type. pointer-type. array-type. file-type. set-type. -declarations -identifier = ; ; Figure 1. -declarations simple- pointer- array- file- set- record- Figure 2. simple- standard- subrange- enumerated- Figure 3. simple- standard- boolean char integer real

More information

Chapter 1: Number and Operations

Chapter 1: Number and Operations Chapter 1: Number and Operations 1.1 Order of operations When simplifying algebraic expressions we use the following order: 1. Perform operations within a parenthesis. 2. Evaluate exponents. 3. Multiply

More information

GCSE-AS Mathematics Bridging Course. Chellaston School. Dr P. Leary (KS5 Coordinator) Monday Objectives. The Equation of a Line.

GCSE-AS Mathematics Bridging Course. Chellaston School. Dr P. Leary (KS5 Coordinator) Monday Objectives. The Equation of a Line. GCSE-AS Mathematics Bridging Course Chellaston School Dr (KS5 Coordinator) Monday Objectives The Equation of a Line Surds Linear Simultaneous Equations Tuesday Objectives Factorising Quadratics & Equations

More information

Bawar Abid Abdalla. Assistant Lecturer Software Engineering Department Koya University

Bawar Abid Abdalla. Assistant Lecturer Software Engineering Department Koya University Logic Design First Stage Lecture No.5 Boolean Algebra Bawar Abid Abdalla Assistant Lecturer Software Engineering Department Koya University Boolean Operations Laws of Boolean Algebra Rules of Boolean Algebra

More information

5-2 Verifying Trigonometric Identities

5-2 Verifying Trigonometric Identities Verify each identity 1 (sec 1) cos = sin sec (1 cos ) = tan 3 sin sin cos 3 = sin 4 csc cos cot = sin 4 5 = cot Page 1 4 5 = cot 6 tan θ csc tan = cot 7 = cot 8 + = csc Page 8 = csc + 9 + tan = sec 10

More information

Concepts Review. 2. A program is the implementation of an algorithm in a particular computer language, like C and C++.

Concepts Review. 2. A program is the implementation of an algorithm in a particular computer language, like C and C++. Concepts Review 1. An algorithm is a sequence of steps to solve a problem. 2. A program is the implementation of an algorithm in a particular computer language, like C and C++. 3. A flowchart is the graphical

More information

CSCE 145 Exam 1 Review. This exam totals to 100 points. Follow the instructions. Good luck!

CSCE 145 Exam 1 Review. This exam totals to 100 points. Follow the instructions. Good luck! CSCE 145 Exam 1 Review This exam totals to 100 points. Follow the instructions. Good luck! Chapter 1 This chapter was mostly terms so expect a fill in the blank style questions on definition. Remember

More information

3 The L oop Control Structure

3 The L oop Control Structure 3 The L oop Control Structure Loops The while Loop Tips and Traps More Operators The for Loop Nesting of Loops Multiple Initialisations in the for Loop The Odd Loop The break Statement The continue Statement

More information

5-2 Verifying Trigonometric Identities

5-2 Verifying Trigonometric Identities 5- Verifying Trigonometric Identities Verify each identity. 1. (sec 1) cos = sin 3. sin sin 3 = sin cos 4 5. = cot 7. = cot 9. + tan = sec Page 1 5- Verifying Trigonometric Identities 7. = cot 9. + tan

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

Dr Richard Greenaway

Dr Richard Greenaway SCHOOL OF PHYSICS, ASTRONOMY & MATHEMATICS 4PAM1008 MATLAB 2 Basic MATLAB Operation Dr Richard Greenaway 2 Basic MATLAB Operation 2.1 Overview 2.1.1 The Command Line In this Workshop you will learn how

More information

Excel R Tips. is used for multiplication. + is used for addition. is used for subtraction. / is used for division

Excel R Tips. is used for multiplication. + is used for addition. is used for subtraction. / is used for division Excel R Tips EXCEL TIP 1: INPUTTING FORMULAS To input a formula in Excel, click on the cell you want to place your formula in, and begin your formula with an equals sign (=). There are several functions

More information

High School MATHEMATICS Trigonometry

High School MATHEMATICS Trigonometry High School MATHEMATICS Trigonometry Curriculum Curriculum Map USD 457 Math Framework Performance/Open-Ended Response Assessments o First Semester (Tasks 1-3) o Second Semester (Tasks 1-4) Available on

More information

XQ: An XML Query Language Language Reference Manual

XQ: An XML Query Language Language Reference Manual XQ: An XML Query Language Language Reference Manual Kin Ng kn2006@columbia.edu 1. Introduction XQ is a query language for XML documents. This language enables programmers to express queries in a few simple

More information

CSCE 206: Structured Programming in C++

CSCE 206: Structured Programming in C++ CSCE 206: Structured Programming in C++ 2017 Spring Exam 2 Monday, March 20, 2017 Total - 100 Points B Instructions: Total of 13 pages, including this cover and the last page. Before starting the exam,

More information

Macro Programming Reference Guide. Copyright 2005 Scott Martinez

Macro Programming Reference Guide. Copyright 2005 Scott Martinez Macro Programming Reference Guide Copyright 2005 Scott Martinez Section 1. Section 2. Section 3. Section 4. Section 5. Section 6. Section 7. What is macro programming What are Variables What are Expressions

More information

CSE123. Program Design and Modular Programming Functions 1-1

CSE123. Program Design and Modular Programming Functions 1-1 CSE123 Program Design and Modular Programming Functions 1-1 5.1 Introduction A function in C is a small sub-program performs a particular task, supports the concept of modular programming design techniques.

More information

CS 376b Computer Vision

CS 376b Computer Vision CS 376b Computer Vision 09 / 25 / 2014 Instructor: Michael Eckmann Today s Topics Questions? / Comments? Enhancing images / masks Cross correlation Convolution C++ Cross-correlation Cross-correlation involves

More information