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