Debian Codegraph @

Help/guide/tutorial/Step9/Tutorial/Tutorial.cxx

raw
1 // A simple program that computes the square root of a number
2 #include <format>
3 #include <iostream>
4 #include <string>
5
6 #include <MathFunctions.h>
7
8 int main(int argc, char* argv[])
9 {
10 if (argc < 2) {
11 std::cout << std::format("Usage: {} number\n", argv[0]);
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 outputValue = mathfunctions::sqrt(inputValue);
20 std::cout << std::format("The square root of {} is {}\n", inputValue,
21 outputValue);
22
23 double const checkValue = mathfunctions::OpMul(outputValue, outputValue);
24 std::cout << std::format("The square of {} is {}\n", outputValue,
25 checkValue);
26 }