Debian Codegraph @

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