summaryrefslogtreecommitdiff
path: root/Tests/Tutorial/Step3/tutorial.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/Tutorial/Step3/tutorial.cxx')
-rw-r--r--Tests/Tutorial/Step3/tutorial.cxx25
1 files changed, 12 insertions, 13 deletions
diff --git a/Tests/Tutorial/Step3/tutorial.cxx b/Tests/Tutorial/Step3/tutorial.cxx
index 37f6ac4567..1d5742d2d1 100644
--- a/Tests/Tutorial/Step3/tutorial.cxx
+++ b/Tests/Tutorial/Step3/tutorial.cxx
@@ -1,8 +1,9 @@
// A simple program that computes the square root of a number
+#include <cmath>
+#include <iostream>
+#include <string>
+
#include "TutorialConfig.h"
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
#ifdef USE_MYMATH
# include "MathFunctions.h"
@@ -11,23 +12,21 @@
int main(int argc, char* argv[])
{
if (argc < 2) {
- fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR,
- Tutorial_VERSION_MINOR);
- fprintf(stdout, "Usage: %s number\n", argv[0]);
+ std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "."
+ << Tutorial_VERSION_MAJOR << std::endl;
+ std::cout << "Usage: " << argv[0] << " number" << std::endl;
return 1;
}
- double inputValue = atof(argv[1]);
- double outputValue = 0;
+ double inputValue = std::stod(argv[1]);
- if (inputValue >= 0) {
#ifdef USE_MYMATH
- outputValue = mysqrt(inputValue);
+ double outputValue = mysqrt(inputValue);
#else
- outputValue = sqrt(inputValue);
+ double outputValue = sqrt(inputValue);
#endif
- }
- fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue);
+ std::cout << "The square root of " << inputValue << " is " << outputValue
+ << std::endl;
return 0;
}