a4f44d54fc2f646cf65a035428b2e0feb68a79c1
[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 <string>
4
5 #include "MathFunctions.h"
6 #include "TutorialConfig.h"
7
8 int main(int argc, char* argv[])
9 {
10   if (argc < 2) {
11     // report version
12     std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "."
13               << Tutorial_VERSION_MINOR << std::endl;
14     std::cout << "Usage: " << argv[0] << " number" << std::endl;
15     return 1;
16   }
17
18   // convert input to double
19   const double inputValue = std::stod(argv[1]);
20
21   const double outputValue = mathfunctions::sqrt(inputValue);
22
23   std::cout << "The square root of " << inputValue << " is " << outputValue
24             << std::endl;
25   return 0;
26 }