diff options
author | Michael Abed <michaelabed@gmail.com> | 2012-02-27 11:12:18 -0500 |
---|---|---|
committer | Michael Abed <michaelabed@gmail.com> | 2012-02-27 11:12:18 -0500 |
commit | 8932ac3c9881f800310e03fb147dce3261989eca (patch) | |
tree | 9336e291f283694c328933fb3ba00e6baa53acc9 /Q1.cpp | |
download | ec327-lab2-8932ac3c9881f800310e03fb147dce3261989eca.tar.gz ec327-lab2-8932ac3c9881f800310e03fb147dce3261989eca.tar.bz2 ec327-lab2-8932ac3c9881f800310e03fb147dce3261989eca.zip |
initial commit
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; +} |