tutorial.cxx 741 B

1234567891011121314151617181920212223242526272829303132
  1. // A simple program that computes the square root of a number
  2. #include <cmath>
  3. #include <iostream>
  4. #include <string>
  5. #include "TutorialConfig.h"
  6. #ifdef USE_MYMATH
  7. # include "MathFunctions.h"
  8. #endif
  9. int main(int argc, char* argv[])
  10. {
  11. if (argc < 2) {
  12. std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "."
  13. << Tutorial_VERSION_MAJOR << std::endl;
  14. std::cout << "Usage: " << argv[0] << " number" << std::endl;
  15. return 1;
  16. }
  17. double inputValue = std::stod(argv[1]);
  18. #ifdef USE_MYMATH
  19. double outputValue = mysqrt(inputValue);
  20. #else
  21. double outputValue = sqrt(inputValue);
  22. #endif
  23. std::cout << "The square root of " << inputValue << " is " << outputValue
  24. << std::endl;
  25. return 0;
  26. }