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

75 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+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents