-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrootTesterN.cpp
More file actions
40 lines (32 loc) · 926 Bytes
/
rootTesterN.cpp
File metadata and controls
40 lines (32 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//===========================================
//rootTesterN.cpp
//Code to test the first square root function
//===============================
#include <iostream>
#include <cmath>
using namespace std;
double squareRootN(double x, int N);
//============>> main << ====================
int main()
{
cout.precision(15); // show lots of digits
double x;
int N;
cout << "Input x and number of iterates [q to quit] :> ";
cin >> x;
cin >> N;
while( not cin.fail())
{
// we have valid input so give it a try
cout<< "squareRootN(" << x << ", " << N << ") = ";
cout<< squareRootN(x, N)<<endl;
cout<< "sqrt(" << x << ") = " << sqrt(x) <<endl;
cout <<"Difference = " << squareRootN(x, N) - sqrt(x)
<< endl;
cout<<"====================================" <<endl;
cout<< "Input x and number of iterates [q to quit] :> ";
cin >> x >> N ;
}
cout<< "Thanks for playing!" << endl;
return 0;
}