1
0

tutorial.cxx 700 B

1234567891011121314151617181920212223242526
  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. // report version
  10. std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "."
  11. << Tutorial_VERSION_MINOR << std::endl;
  12. std::cout << "Usage: " << argv[0] << " number" << std::endl;
  13. return 1;
  14. }
  15. // convert input to double
  16. double const inputValue = std::stod(argv[1]);
  17. double const outputValue = mathfunctions::sqrt(inputValue);
  18. std::cout << "The square root of " << inputValue << " is " << outputValue
  19. << std::endl;
  20. return 0;
  21. }