Path: blob/master/Help/guide/tutorial/Step1/Tutorial/Tutorial.cxx
5020 views
// A simple program that computes the square root of a number
#include <cmath>
#include <iostream>
#include <string>
// TODO8: Include the MathFunctions header
int main(int argc, char* argv[])
{
if (argc < 2) {
std::cout << "Usage: " << argv[0] << " number" << std::endl;
return 1;
}
// convert input to double
double const inputValue = std::stod(argv[1]);
// TODO9: Use the mathfunctions::sqrt function
// calculate square root
double const outputValue = std::sqrt(inputValue);
std::cout << "The square root of " << inputValue << " is " << outputValue
<< std::endl;
}