Write a C++ function that accept one input argument only. The input could be a string, int, float or double. If the input is string, the function returns its number of characters. If the input is integer, the function returns its number of digits. If the input is float, the function returns its number of digits before the point (for example, if the number is 8502.56, the function returns 4). If the input is double, the function returns its number of digits before the point and its number of digits after the point (for example, if the number is 120.5654, the function returns 3 and 4). Then, write a C++ program to test your function by entering the following values: “Quiz1” for string, -5000 for int, 9864.1 for float, and 801.651237 for double.
2- Write a C++ function that accept one input argument only. The input could be a
string, int, float or double. If the input is string, the function returns its number of
characters. If the input is integer, the function returns its number of digits. If the
input is float, the function returns its number of digits before the point (for example,
if the number is 8502.56, the function returns 4). If the input is double, the function
returns its number of digits before the point and its number of digits after the point
(for example, if the number is 120.5654, the function returns 3 and 4). Then, write a
C++ program to test your function by entering the following values: “Quiz1” for
string, -5000 for int, 9864.1 for float, and 801.651237 for double.
Step by step
Solved in 2 steps