tutorial.cxx 633 B

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