{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

finalreport6

# finalreport6 - Benjamin Jones Final Report Laboratory 6...

This preview shows pages 1–3. Sign up to view the full content.

Benjamin Jones 02/14/08 Final Report Laboratory 6 Program Source Code Header File: // *********************************************************************** // File: findroots.h // // Stats of a list of data - User enters a number to take a root of, the root // to take of that number, a desired precision, and the program will output // the root of that number to the given precision. // // // // Author: Benjamin Jones // Created: 14 February 2008 // Updated: Original // // Assignment: Lab 6 // Compiler: gcc version 4.1.1 // // ************************************************************************ // // Function Organization: // // 2. Calculate the nth root of the number to a given precision // 2.A Set the current value equal to the number to root over the root // 2.B Intialize the new value, as well as the difference comparison // 2.C If nth root is zero (no need to compute) // 2.C.I Exit function returning the nth root // 2.D While the abolute value of the difference of the current value // and the new value is greater than the desired precision // 2.D.I If new value is not zero (not the first time through // the loop) // 2.D.I.a Set current value equal to old value // 2.D.II Set new value equal to the reciprocal of the root we // we are taking multiplied by the quantity of the // current value multiplied by the nth root minus one // added to the quantity of the number we are taking // the root of divided by the current value to the power // of the nth root minus one. // 2.E Find the difference of the current value and the new value // 2.F Return the new value // // ********************************************************************** #ifndef FINDROOT_H

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
#define FINDROOT_H #endif #include <iostream> #include <string> #include <cmath> using namespace std; const int OK = 0; const int NOTOK = 1; // 2. Calculate the nth root of the number to a given precision double findNthRoot(double numberToRoot = 0.0, double nthRoot = 2.0, double desiredPrecision = 10e-9) { // Function calculates the nth root of the number to a given precision //
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern