diff options
Diffstat (limited to 'Q1.cpp')
-rw-r--r-- | Q1.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -0,0 +1,28 @@ + +#include <iostream> +#include <cmath> + +#include "mysqrt.h" + +using namespace std; +int main() +{ + double input; + double sq, mysq; + + do { // + cout << "Enter a number (negative to quit)" << endl; + cout << ">> "; + cin >> input; + if (input >= 0) { + mysq = mysqrt(input); + sq = sqrt(input); + cout << "mysqrt(" << input << ") = " << mysq << endl; + cout << "sqrt(" << input << ") = " << sq << endl; + cout << "sqrt and mysqrt differ by " << abs(sq - mysq) << endl; + } + + } while (input >= 0); + + return 0; +} |