tutorial.cxx 611 B

1234567891011121314151617181920212223
  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. std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "."
  10. << Tutorial_VERSION_MAJOR << std::endl;
  11. std::cout << "Usage: " << argv[0] << " number" << std::endl;
  12. return 1;
  13. }
  14. double inputValue = std::stod(argv[1]);
  15. double outputValue = sqrt(inputValue);
  16. std::cout << "The square root of " << inputValue << " is " << outputValue
  17. << std::endl;
  18. return 0;
  19. }