#include <iostream>
using namespace std;
void setThreshold(int x) {
cout << "Threshold set to " << x;
}
void setThreshold(double x) {
cout << "Threshold set to " << x;
}
int main() {
double val;
cin >> val;
if (val == (int)val) {
setThreshold((int)val); // integer overload
} else {
setThreshold(val); // double overload
}
return 0;
}Solution Details
setThreshold but different parameter types (int and double).main() handles whether the value is whole (int) or decimal (double). 👉 In simple words:
You only write the two versions of setThreshold. The program chooses which one to call depending on whether the input has decimals.
Significance for Embedded Developers
ADC = 1023) or in real units (e.g., volts = 3.75).