#include <iostream> using namespace std; void printValue(int x) { cout << "Value=" << x; } void printValue(float x) { cout << "Value=" << x; } int main() { float val; cin >> val; if (val == (int)val) { printValue((int)val); } else { printValue(val); } return 0; }
Solution Details
👉 In simple words: You only write the two functions. The program will figure out which one to use.
Significance for Embedded Developers
Function overloading provides a clean way to handle both without writing different function names.
Test Cases
Test Results
Input
42
Expected Output
Value=42