Imported Upstream version 3.25.0
[platform/upstream/cmake.git] / Help / guide / tutorial / Step11 / tutorial.cxx
1 // A simple program that computes the square root of a number
2 #include <iostream>
3 #include <sstream>
4 #include <string>
5
6 #include "MathFunctions.h"
7 #include "TutorialConfig.h"
8
9 int main(int argc, char* argv[])
10 {
11   if (argc < 2) {
12     // report version
13     std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "."
14               << Tutorial_VERSION_MINOR << std::endl;
15     std::cout << "Usage: " << argv[0] << " number" << std::endl;
16     return 1;
17   }
18
19   // convert input to double
20   const double inputValue = std::stod(argv[1]);
21
22   const double outputValue = mathfunctions::sqrt(inputValue);
23
24   std::cout << "The square root of " << inputValue << " is " << outputValue
25             << std::endl;
26   return 0;
27 }