tutorial.cxx 719 B

123456789101112131415161718192021222324252627
  1. // A simple program that computes the square root of a number
  2. #include <iostream>
  3. #include <sstream>
  4. #include <string>
  5. #include "MathFunctions.h"
  6. #include "TutorialConfig.h"
  7. int main(int argc, char* argv[])
  8. {
  9. if (argc < 2) {
  10. // report version
  11. std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "."
  12. << Tutorial_VERSION_MINOR << std::endl;
  13. std::cout << "Usage: " << argv[0] << " number" << std::endl;
  14. return 1;
  15. }
  16. // convert input to double
  17. double const inputValue = std::stod(argv[1]);
  18. double const outputValue = mathfunctions::sqrt(inputValue);
  19. std::cout << "The square root of " << inputValue << " is " << outputValue
  20. << std::endl;
  21. return 0;
  22. }