tutorial.cxx 672 B

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