1 Math Expressions and Operators. 2 Some C++ Operators Precedence OperatorDescription Higher ( )Function call +Positive - Negative *Multiplication / Division.

Slides:



Advertisements
Similar presentations
Arithmetic Calculations
Advertisements

Chapter 4 Methods F Introducing Methods –Benefits of methods, Declaring Methods, and Calling Methods F Passing Parameters –Pass by Value F Overloading.
Functions. COMP104 Functions / Slide 2 Introduction to Functions * A complex problem is often easier to solve by dividing it into several smaller parts,
Building Java Programs
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 13 Fall 2010.
1 MATH METHODS THAT RETURN VALUES. 2 JAVA'S MATH CLASS.
Return values.
Excel Part I Basics and Simple Plotting Section 008 Fall 2013 EGR 105 Foundations of Engineering I.
MATLAB MATLAB is a high-level technical computing language and
Maths & Trig, Statistical functions. ABS Returns the absolute value of a number The absolute value of a number is the number without its sign Syntax ◦
Chapter 3: Expressions and Interactivity. Outline cin object Mathematical expressions Type Conversion and Some coding styles.
1 Lecture 6 Chapter 3 Numeric Types, Expressions, and Output Dale/Weems/Headington.
Lecture 6 MATLAB functions Basics of Built-in Functions, Help Feature, Elementary Functions (e.g., Polynomials, Trigonometric Functions), Data Analysis,
1 Fundamental Data types Overview l Primitive Data Types l Variable declaration l Arithmetical Operations l Expressions l Assignment statement l Increment.
1 Chapter 3 Arithmetic Expressions. 2 Chapter 3 Topics l Overview of Java Data Types l Numeric Data Types l Declarations for Numeric Expressions l Simple.
1 Chapter 3 Topics Constants of Type int and float l Evaluating Arithmetic Expressions l Implicit Type Coercion and Explicit Type Conversion l Calling.
ICS 103 Lab 2-Arithmetic Expressions. Lab Objectives Learn different arithmetic operators Learn different arithmetic operators Learn how to use arithmetic.
Introduction to Matlab. Entering Commands Constants and Functions >> pi ans = >> eps ans = e-016 >> sin(pi/2) ans = 1 >> log(1000) ans =
EGR 105 Foundations of Engineering I Session 3 Excel – Basics through Graphing Fall 2008.
1 Python Chapter 2 © Samuel Marateck, After you install the compiler, an icon labeled IDLE (Python GUI) will appear on the screen. If you click.
1 Data types, operations, and expressions Continued l Overview l Assignment statement l Increment and Decrement operators l Short hand operators l The.
Raptor Mr. Lau Ka Lun Lai King Catholic Secondary School.
Data Types, Expressions and Functions (part I)
Introduction to touchdevelop math basic arithmetic operations Disclaimer: This document is provided “as-is”. Information and views expressed in this document,
Microsoft® Small Basic The Math Object Estimated time to complete this lesson: 1 hour.
INTRODUCTION TO PYTHON PART 1 CSC482 Introduction to Text Analytics Thomas Tiahrt, MA, PhD.
1 CS101 Introduction to Computing Lecture 35 Mathematical Methods (Web Development Lecture 12)
Introduction to MATLAB ENGR 1187 MATLAB 1. Programming In The Real World Programming is a powerful tool for solving problems in every day industry settings.
CSC 107 – Programming For Science. Announcements  Lectures may not cover all material from book  Material that is most difficult or challenging is focus.
Python  By: Ben Blake, Andrew Dzambo, Paul Flanagan.
1 TAC2000/ Protocol Engineering and Application Research Laboratory (PEARL) MATH Functions in C Language.
CSE1222: Lecture 4The Ohio State University1. Mathematical Functions (1)  The math library file cmath Yes, this is a file with definitions for common.
Computer Science 111 Fundamentals of Programming I Basic Program Elements.
ENG 1181 College of Engineering Engineering Education Innovation Center MATLAB is a powerful program for numerical computations, plotting and programming.
Introduction to MATLAB ENGR 1181 MATLAB 1. Programming In The Real World Programming is a powerful tool for solving problems in every day industry settings.
CSE202: Lecture 4The Ohio State University1 Mathematical Functions.
Chapter 5 NUTS AND BOLTS: STANDARD STUFF IN C++. Chapter 5 The C++ Arithmetic Operators –Addition+ –Subtraction– –Multiplication  –Division/ –Modulus.
Introduction to Engineering MATLAB – 1 Introduction to MATLAB Agenda Introduction Arithmetic Operations MATLAB Windows Command Window Defining Variables.
Variables and Arithmetic. From last class More drawing functions: strokeWeight(n); // higher the n value broader the stroke fill(k) ; // single parameter.
1 Chapter 3 Numeric Types, Expressions, and Output Dale/Weems/Headington.
Math With Java The Math Class. First, A Quick Review of Math Operators in Java Primitive Data type in Java that represent numbers: Primitive Data type.
CSC 107 – Programming For Science. Announcements  Lectures may not cover all material from book  Material that is most difficult or challenging is focus.
Chapter 3 Arithmetic Expressions, Function Calls, and Output
1 Chapter 3 Numeric Types, Expressions, and Output Dale/Weems/Headington.
Getting Started with MATLAB (part 3) 1. Algebra, 2. Trig 3. The keyword ans 4. Clean up and suppress output: finalizing the software’s presentation 1.
Chapter 6 Mathematical Operations. 6.1 Mathematical Expressions In mathematics this expression is valid 0 = -4y + 5 It is invalid in programming Left.
ENG 1181 First-Year Engineering Program College of Engineering Engineering Education Innovation Center First-Year Engineering Program MAT - Introduction.
PHY 107 – Programming For Science. Announcements  Lectures may not cover all material from readings  Material that is most difficult or challenging.
29 January 2016Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems.
C++ Data Types Check sample values of? ‘4’
MATLAB Constants, Variables & Expression Nafees Ahmed Asstt. Professor, EE Deptt DIT, DehraDun.
ICS 3U Math Class. ActionScript 3 – Math Class Rounding ceil – closest integer >= number (rounds up) floor – closest integer
Matlab Tutorial Iman Moazzen First Session – September 11, 2013.
Useful Python CMSC 120: Visualizing Information. Scope def area(diameter): radius = diameter / 2.0 A = PI * radius ** 2 return A def circumference(diameter):
Mathematical Manipulation Data types Operator precedence Standard mathematical functions Worked examples.
1 Lecture Three I/O Formatting and Arithmetic Dr. Sherif Mohamed Tawfik.
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
Think Automation and beyond… FT1A Script Programming.
Chapter INTRODUCTION Data Types and Arithmetic Calculations.
1 Chapter 3 Numeric Types, Expressions, and Output Dale/Weems/Headington.
CSE 110: Programming Language I Afroza Sultana UB 1230.
Variables, Operators, and Expressions
Some Useful MATLAB Functions
BIL 104E Introduction to Scientific and Engineering Computing
TMF1414 Introduction to Programming
Introduction to Programming
Operators and Expressions
Variables and Arithmetic
Terminal-Based Programs
Presentation transcript:

1 Math Expressions and Operators

2 Some C++ Operators Precedence OperatorDescription Higher ( )Function call +Positive - Negative *Multiplication / Division % Modulus (remainder) +Addition - Subtraction Lower = Assignment

3 Associativity l left to right Associativity means that in an expression having 2 operators with the same priority, the left operator is applied first l in C++ the binary operators *, /, %, +, - are all left associative l expression means ( )

4 7 * % 3 * means (7 * 10) - 5 % 3 * % 3 * (5 % 3) * * ( 2 * 4 ) ( ) Evaluate the Expression

5 What value is stored? var a; var b; a = 8.5; b = 9.37; a = b; a b a b ? ?

Built-in Variables l mouseX - current x position of the mouse cursor l mouseY - current y position of the mouse cursor l width - width of the screen l height - height of the screen l PI 6

7 FUNCTION EXAMPLE VALUE OF CALL abs(x) abs(-6.4) 6.4 pow(x,y) pow(2.0,3.0) 8.0 sqrt(x) sqrt(100.0) 10.0 log(x) n.log log(2.0) sqrt(x) sqrt(2.0) abs(i) abs(-6) 6

More Functions Calculations l abs() l ceil() l dist() – between 2 pts l exp() l floor() l log() – common log l max() - largest value l min() – smallest value l pow() l round() l sq() l sqrt() Trigonometry l sin() l cos() l tan() l acos() l asin() l atan() l degrees() - rad to deg l radians() - deg to rad 8

9 Write C++ Expressions for The square root of b 2 - 4ac sqrt ( b*b - 4.0*a*c ) The square root of the average of myAge and yourAge sqrt ( ( myAge + yourAge ) / 2. )

10 Draw Function var draw = function() { : point(random(400), random(400)); : } l Executes repeatedly l Default frameRate is 60 fps (less on slower computer) l frameCount n # frames drawn