From 8932ac3c9881f800310e03fb147dce3261989eca Mon Sep 17 00:00:00 2001 From: Michael Abed Date: Mon, 27 Feb 2012 11:12:18 -0500 Subject: initial commit --- Q1.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Q1.cpp (limited to 'Q1.cpp') 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 +#include + +#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; +} -- cgit v1.2.3