From 057dbbd2510a6bc96bc31d70115627c4c2198b40 Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 5 Nov 2014 17:48:36 +0100 Subject: [PATCH] Remove hello.h and add the possibility of taking the square root of a negative number --- SimpleExecutable/hello.h | 3 --- SimpleExecutable/main.cc | 16 +++++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) delete mode 100644 SimpleExecutable/hello.h diff --git a/SimpleExecutable/hello.h b/SimpleExecutable/hello.h deleted file mode 100644 index a81e8c0..0000000 --- a/SimpleExecutable/hello.h +++ /dev/null @@ -1,3 +0,0 @@ -#include - -void hello(); diff --git a/SimpleExecutable/main.cc b/SimpleExecutable/main.cc index 76a9e99..9369f09 100644 --- a/SimpleExecutable/main.cc +++ b/SimpleExecutable/main.cc @@ -3,8 +3,6 @@ #include #include -// #include "hello.h" - int main (int argc, char *argv[]) { if (argc < 2) @@ -13,9 +11,17 @@ int main (int argc, char *argv[]) return 1; } double inputValue = atof(argv[1]); - double outputValue = sqrt(inputValue); - fprintf(stdout,"The square root of %g is %g\n", - inputValue, outputValue); + double outputValue = sqrt(abs(inputValue)); + if ( inputValue >= 0. ) + { + fprintf(stdout,"The square root of %g is %g\n", + inputValue, outputValue); + } + else + { + fprintf(stdout,"The square root of %g is %g x i\n", + inputValue, outputValue); + } // hello(); return 0;