1
0

main.cc 535 B

1234567891011121314151617181920212223
  1. // A simple program that outputs the square root of a number
  2. #include <iostream>
  3. #include <string>
  4. #include "MathFunctions.h"
  5. int main(int argc, char* argv[])
  6. {
  7. if (argc < 2) {
  8. std::cout << "Usage: " << argv[0] << " number" << std::endl;
  9. return 1;
  10. }
  11. // convert input to double
  12. const double inputValue = std::stod(argv[1]);
  13. // calculate square root
  14. const double sqrt = MathFunctions::sqrt(inputValue);
  15. std::cout << "The square root of " << inputValue << " is " << sqrt
  16. << std::endl;
  17. return 0;
  18. }