I wrote a simple program to calculate the hypotenuse length of a triangle. My question is, how can I give variables "side1" and "side2" values while executing the main function from the terminal? Code below:
#include <iostream>
#include <cmath>
int main(int side1, int side2) {
int c2 = (pow(side1, 2)) + (pow(side2, 2));
std::cout << sqrt(c2) << std::endl;
return 0;
}
The function compiles without error, so normally I would execute the function from terminal using "./main.exe", but is there a way to pass values to variables side1 & side2 while executing? (ex: ./main.exe "5" "5"). I don't want to go the std::cin route because I already know how to do that. For the same reason, I don't want to assign values to the variables within the function (ex: int side1 {5};).
I don't know if this is possible to do or not, but sites like Leetcode have their functions set up this way, and I have no clue how they input values for test cases.