tutorial.cxx 552 B

12345678910111213141516171819
  1. // A simple program that computes the square root of a number
  2. #include "TutorialConfig.h"
  3. #include <math.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. int main(int argc, char* argv[])
  7. {
  8. if (argc < 2) {
  9. fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR,
  10. Tutorial_VERSION_MINOR);
  11. fprintf(stdout, "Usage: %s number\n", argv[0]);
  12. return 1;
  13. }
  14. double inputValue = atof(argv[1]);
  15. double outputValue = sqrt(inputValue);
  16. fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue);
  17. return 0;
  18. }