Debian Codegraph @

Help/guide/tutorial/Step5/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 // TODO11: Check the calculated square root using mathfunctions::OpMul to
24 // square the outputValue. Output the result with the format:
25 // "The square of {} is {}\n"
26 }