Download presentation
Presentation is loading. Please wait.
Published byMary Leger Modified over 10 years ago
1
Adapted from Pearson Addison-Wesley. Addison Wesley is an imprint of Chapter 3: Math Functions Adapted from Problem Solving & Program Design in C Sixth Edition By Jeri R. Hanly & Elliot B. Koffman
2
1-2 © 2010 Pearson Addison-Wesley. All rights reserved. 1-2 Figure 3.2 Outline of Program Circle
3
1-3 © 2010 Pearson Addison-Wesley. All rights reserved. 1-3 Figure 3.3 Calculating the Area and the Circumference of a Circle
4
1-4 © 2010 Pearson Addison-Wesley. All rights reserved. 1-4 Figure 3.3 Calculating the Area and the Circumference of a Circle (cont’d)
5
1-5 © 2010 Pearson Addison-Wesley. All rights reserved. 1-5 Figure 3.4 Computing the Rim Area of a Flat Washer
6
1-6 © 2010 Pearson Addison-Wesley. All rights reserved. 1-6 Flat Washer Program
7
1-7 © 2010 Pearson Addison-Wesley. All rights reserved. 1-7 Flat Washer Program (cont’d)
8
1-8 © 2010 Pearson Addison-Wesley. All rights reserved. 1-8 Figure 3.6 Function sqrt as a “Black Box”
9
1-9 © 2010 Pearson Addison-Wesley. All rights reserved. 1-9 Figure 3.7 Square Root Program
10
1-10 © 2010 Pearson Addison-Wesley. All rights reserved. 1-10 Figure 3.7 Square Root Program (cont’d)
11
1-11 © 2010 Pearson Addison-Wesley. All rights reserved. 1-11 Common Mathematical Library Functions Function Standard header fileArgument(s) Result abs(x)stdlib.hint fabs(x)math.hdouble ceil(x)math.hdouble floor(x)math.hdouble cos(x), sin(x) and tan(x) math.hdouble
12
1-12 © 2010 Pearson Addison-Wesley. All rights reserved. 1-12 Common Mathematical Library Functions Function Standard header fileArgument(s) Result exp(x)math.hdouble log(x)math.hdouble log10(x)math.hdouble pow(x, y)math.hdouble, double double sqrt(x)math.hdouble
13
1-13 © 2010 Pearson Addison-Wesley. All rights reserved. 1-13 Example Formula to calculate unknown side “a” of a triangle a 2 =b 2 + c 2 – 2bc cosα
14
1-14 © 2010 Pearson Addison-Wesley. All rights reserved. 1-14 Triangle with Unknown Side a After defining a, b, c, PI and alpha a = sqrt(pow(b,2) + pow (c,2) – 2*b*c* cos (alpha*PI /180.0));
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.