Math Library Functions

Slides:



Advertisements
Similar presentations
Objective: You will learn how to determine if a number is a perfect square and how to find the square root of perfect squares.
Advertisements

Functions. COMP104 Functions / Slide 2 Introduction to Functions * A complex problem is often easier to solve by dividing it into several smaller parts,
Looping while … do …. Condition Process 2 Process 1 Y Repeated Loop.
Lab 8 User Defined Function.
Chapter 6: User-Defined Functions I
11.3 Function Prototypes A Function Prototype contains the function’s return type, name and parameter list Writing the function prototype is “declaring”
Library of Functions; Piecewise-defined Functions February 5, 2007.
ICS 103 Lab 2-Arithmetic Expressions. Lab Objectives Learn different arithmetic operators Learn different arithmetic operators Learn how to use arithmetic.
12-2 Know how if and switch C statements control the sequence of execution of statements. Be able to use relational and logical operators in the conditional.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Java Programs COMP 102 #3.
Library of Functions.
Computational physics PY2050 Course Details:
What are functions? 1. A piece of code that performs an operation that can be used by the main program or by other functions 2. A sophisticated if –else.
Chapter 3 Expressions and Interactivity Department of Computer Science Missouri State Univeristy.
Array Cs212: DataStructures Lab 2. Array Group of contiguous memory locations Each memory location has same name Each memory location has same type a.
Sept 18, 2007Sprenkle - CS111 Lab 0 Feedback Great! Great! Details got some of you Details got some of you  Print out copy  Copy directory to turnin.
Agenda Review C++ Library Functions Review User Input Making your own functions Exam #1 Next Week Reading: Chapter 3.
Objectives: Graph the functions listed in the Library of Functions
Math notebook, calculator & pencil Cube Roots. Last Week Last week we focused on factoring the square roots of numbers and solving equations with square.
Even more problems.. Mean (average) I need a program that calculates the average of student test scores. I need a program that calculates the average.
Calculations Chapter 11 Library of math functions, and constants cos, sin, tan, abs, min, max, log, random, sqrt, pow, exp Constants.PI,.E Use care with.
CS Class 08 Today  Exercises  Nested loops  for statement  Built-in functions Announcements  Homework #3, group solution to in-class.
Math – What is a Function? 1. 2 input output function.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 3: Introduction to C: Input & Output, Assignments, Math functions.
X Tours Coordinator: Prof. Yves Lansac Université François Rabelais, Tours, Loire Vallée, France.
10/25: Methods & templates Return to concepts: methods Math class methods Program of the day.
Chapter 4 10/26 & 10/27. More Linux Commands mkdir rmdir echo > redirect output mv file, directory mv oldFileName newFileName more file rm file.
On Desk: 1.Pencil 2.Math Journal 3.Learning Log Learning Log: HW: WS -Adding & Subtracting Integers (D) Parent Sig. on SD – Log Unit Test returned after.
Standard Deviation A Measure of Variation in a set of Data.
Recap……Last Time [Variables, Data Types and Constants]
Unit 3 Test Review – Identifying Parent Functions October 30, 2014.
Computer Science I: Understand how to evaluate expressions with DIV and MOD Random Numbers Reading random code Writing random code Odds/evens/…
USING & CREATING FUNCTIONS. MODULAR PROGRAMMING  Why Modular Programming?  Improves Readability & Understandability  Improve Maintainability  Allows.
Dayu Zhang 9/10/2014 Lab03. Outline Brief Review of the 4 Steps in Hello.cpp Example Understand endl and \n Understand Comment Programming Exercise -
Special Methods in Java. Mathematical methods The Math library is extensive, has many methods that you can call to aid you in your programming. Math.pow(double.
CSC1201: Programming Language 2 1 Functions. 2 Function declaration: return_type FuncName( Type arg1, Type arg2,….. Type argN) { function body } A program.
Introduction to MATLAB ENGR 1181 MATLAB 1. MATLAB Built-in Math Functions  Pre-defined in MATLAB ready for use exp(x) – exponential (e x ) log(x) – natural.
160 as a product of its prime factors is 2 5 x 5 Use this information to show that 160 has 12 factors.
© Peter Andreae Java Programs COMP 102 # T1 Peter Andreae Computer Science Victoria University of Wellington.
ZyBooks /12/16. Exam I 2/19/16 Review next week.
14.0 Math Review 14.1 Using a Calculator Calculator
Chapter 5: Preparing C Programs
Automating Builds with Makefiles
Chapter 6: User-Defined Functions I
Library Functions Goals of software engineering reliable code
INC 161 , CPE 100 Computer Programming
ECE Application Programming
Chapter 4 Procedural Abstraction and Functions That Return a Value 1
25 Math Review Part 1 Using a Calculator
Some problems for your consideration
Square Roots Practice © T Madas.
Lecture2.
User-Defined Functions
Functions Declarations CSCI 230
CSC1201: Programming Language 2
Computers & Programming Languages
Why do you learn square roots?
Calculators and logs Logarithmic equations
I can find square roots and compare real numbers.
SQUARE ROOTS.
CS110D Programming Language I
Warm Up Find the x-intercept of each function. 1. f(x) = –3x + 9 3
No calculators allowed
Elementary Programming (C++)
Chapter 6: User-Defined Functions I
Hacettepe University Computer Engineering Department
Solving Square Root Equations
CSC1201: Programming Language 2
Lab 4: Introduction to Scripting
Chapter 4 Procedural Abstraction and Functions That Return a Value 1
Presentation transcript:

Math Library Functions 02/12/15

Objective Use functions from the math.h library to do special calculations.

Side of Bandana Problem I am manufacturing bandanas. Given the amount of cloth I can afford for each bandana, I want to know the measure of the side of that square. Write a program to find out the measure of the side of the square bandana.

Algorithm 1. Input a 2. 3. Output s

Program bandana.c

Built-in Functions Call Syntax: fname(arg1, arg2,… argn)‏ Example: s = sqrt(area); Include #include <math.h> Must use -lm option when compiling gcc -lm prog.c

Some Functions in cmath

Some Functions in cmath

Absolute Value of Integers

More Functions in cmath Examples log(88.5) --> 4.483 exp(4.483) --> 88.5

Example Write a program to find the 4th root of a number input by the user. fourthRoot.c

Find Age Difference Write a program to find the difference in age between two quarterbacks on a team.

Algorithm Input qb1 and qb2 difference = |qb1 – qb2| Output difference Write the program today in lab. Started in qb.c