Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Kitware
GitHub Repository: Kitware/CMake
Path: blob/master/Help/guide/importing-exporting/DownstreamComponents/main.cc
5017 views
1
// A simple program that outputs the square root of a number
2
#include <iostream>
3
#include <string>
4
5
#include "Addition.h"
6
#include "SquareRoot.h"
7
8
int main(int argc, char* argv[])
9
{
10
if (argc < 2) {
11
std::cout << "Usage: " << argv[0] << " number" << std::endl;
12
return 1;
13
}
14
15
// convert input to double
16
double const inputValue = std::stod(argv[1]);
17
18
// calculate square root
19
double const sqrt = MathFunctions::sqrt(inputValue);
20
std::cout << "The square root of " << inputValue << " is " << sqrt
21
<< std::endl;
22
23
// calculate sum
24
double const sum = MathFunctions::add(inputValue, inputValue);
25
std::cout << inputValue << " + " << inputValue << " = " << sum << std::endl;
26
27
return 0;
28
}
29
30