tutorial.cxx 589 B

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