tutorial.cxx 684 B

1234567891011121314151617181920212223242526
  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. double inputValue = std::stod(argv[1]);
  17. const double outputValue = mathfunctions::sqrt(inputValue);
  18. std::cout << "The square root of " << inputValue << " is " << outputValue
  19. << std::endl;
  20. return 0;
  21. }