{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

finalreport6 - Benjamin Jones Final Report Laboratory 6...

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

View Full Document Right Arrow Icon
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
Image of page 1

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

View Full Document Right Arrow Icon
#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 //
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern