| 1 |
// A simple program that computes the square root of a number |
| 2 |
|
| 3 |
// TODO3: Include <format> |
| 4 |
|
| 5 |
#include <iostream> |
| 6 |
#include <string> |
| 7 |
|
| 8 |
#include <MathFunctions.h> |
| 9 |
|
| 10 |
int main(int argc, char* argv[]) |
| 11 |
{ |
| 12 |
if (argc < 2) { |
| 13 |
// TODO4: Convert the print to use std::format |
| 14 |
std::cout << "Usage: " << argv[0] << " number" << std::endl; |
| 15 |
return 1; |
| 16 |
} |
| 17 |
|
| 18 |
// convert input to double |
| 19 |
double const inputValue = std::stod(argv[1]); |
| 20 |
|
| 21 |
// calculate square root |
| 22 |
double const outputValue = mathfunctions::sqrt(inputValue); |
| 23 |
// TODO5: Convert the print to use std::format |
| 24 |
std::cout << "The square root of " << inputValue << " is " << outputValue |
| 25 |
<< std::endl; |
| 26 |
} |