MECH 215 Lecture Notes - Lecture 4: C Mathematical Functions, Function Prototype, Quadratic Equation

74 views10 pages

Document Summary

In this section we turn our attention to using predefined library functions. We have already seen a limited use of library functions (recall the use of the fabs library function). In order to access a function within a particular library is is neccessary to #include in your c++ program. Before discussing the different libraries available in c++, we will give an example of the sqrt function which is found in the cmath library (or the old c math. h library). sqrt function. The two real roots of the general quadratic equation: 2 ax + bx + c = 0 , 2 are given by the formula : x = -b +- sqrt(b - 4ac) 2a (we will omit complex roots for the time being). The following program reads in three doubles for the values of a,b,c. If this is true, then it computes the two real roots by passing a value to the sqrt library function:

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents