Download presentation
1
Math Library Functions
02/12/15
2
Objective Use functions from the math.h library to do special calculations.
3
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.
4
Algorithm 1. Input a 2. 3. Output s
5
Program bandana.c
6
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
7
Some Functions in cmath
8
Some Functions in cmath
9
Absolute Value of Integers
10
More Functions in cmath
Examples log(88.5) --> exp(4.483) --> 88.5
11
Example Write a program to find the 4th root of a number input by the user. fourthRoot.c
12
Find Age Difference Write a program to find the difference in age between two quarterbacks on a team.
13
Algorithm Input qb1 and qb2 difference = |qb1 – qb2| Output difference
Write the program today in lab. Started in qb.c
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.