tutorial.cxx 469 B

1234567891011121314151617181920
  1. // A simple program that computes the square root of a number
  2. #include <cmath>
  3. #include <cstdlib>
  4. #include <iostream>
  5. #include <string>
  6. int main(int argc, char* argv[])
  7. {
  8. if (argc < 2) {
  9. std::cout << "Usage: " << argv[0] << " number" << std::endl;
  10. return 1;
  11. }
  12. double inputValue = atof(argv[1]);
  13. double outputValue = sqrt(inputValue);
  14. std::cout << "The square root of " << inputValue << " is " << outputValue
  15. << std::endl;
  16. return 0;
  17. }