Skip to content

Commit

Permalink
Remove hello.h and add the possibility of taking the square root of a…
Browse files Browse the repository at this point in the history
… negative number
  • Loading branch information
pjanot committed Nov 5, 2014
1 parent 4870609 commit 057dbbd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 0 additions & 3 deletions SimpleExecutable/hello.h

This file was deleted.

16 changes: 11 additions & 5 deletions SimpleExecutable/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include <stdlib.h>
#include <math.h>

// #include "hello.h"

int main (int argc, char *argv[])
{
if (argc < 2)
Expand All @@ -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;
Expand Down

0 comments on commit 057dbbd

Please sign in to comment.