Debian Codegraph @

Help/guide/tutorial/Complete/TutorialProject/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 #include <Unpackaged.h>
8
9 int main(int argc, char* argv[])
10 {
11 if (argc < 2) {
12 std::cout << std::format("Usage: {} number\n", argv[0]);
13 return 1;
14 }
15
16 // convert input to double
17 double const inputValue = std::stod(argv[1]);
18
19 // calculate square root
20 double const outputValue = mathfunctions::sqrt(inputValue);
21 std::cout << std::format("The square root of {} is {}\n", inputValue,
22 outputValue);
23
24 double const checkValue = mathfunctions::OpMul(outputValue, outputValue);
25 std::cout << std::format("The square of {} is {}\n", outputValue,
26 checkValue);
27 }