summaryrefslogtreecommitdiff
path: root/Q1.cpp
diff options
context:
space:
mode:
authorMichael Abed <michaelabed@gmail.com>2012-02-27 11:12:18 -0500
committerMichael Abed <michaelabed@gmail.com>2012-02-27 11:12:18 -0500
commit8932ac3c9881f800310e03fb147dce3261989eca (patch)
tree9336e291f283694c328933fb3ba00e6baa53acc9 /Q1.cpp
downloadec327-lab2-8932ac3c9881f800310e03fb147dce3261989eca.tar.gz
ec327-lab2-8932ac3c9881f800310e03fb147dce3261989eca.tar.bz2
ec327-lab2-8932ac3c9881f800310e03fb147dce3261989eca.zip
initial commit
Diffstat (limited to 'Q1.cpp')
-rw-r--r--Q1.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/Q1.cpp b/Q1.cpp
new file mode 100644
index 0000000..6b23316
--- /dev/null
+++ b/Q1.cpp
@@ -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;
+}