Why don't you try this... If the value is a double then when it is rounded with floor() the new value will be different, however if it's an integer then floor() will not effect the value.
My only concern is if you enter something such as 3.0 whether your compiler will choose to treat 3.0 as the same as 3, or whether it says they're different values.
If this does happen then I suppose you can compare floor(test) to ceil(test) and they should equal the same for an integer no matter what strange things the compiler might do.
1 2 3 4 5 6 7 8 9 10 11
#include <cmath>
#include <stdio>
int main(){
double test
scanf("%f", &test)
if(floor(test) == test)
printf("Integer");
else
printf("Double");
}
abhishekm71's method is risky because if you, for example, have some calculated numbers whose result mathematically should be exactly some integer, it may actually not be due to the inherent imprecision of floating point arithmetic. This would cause the difference to be not exactly 0.
Ciu's method is not really useful as it will just call the function based on the type of what you pass it. If you pass 3, it will cal the int version but if you pass 3.0f it'll call the float version, which may not be the result you want.
SatsumaBenji's method has the same issue as abhishekm71's, causing a calculation result to not exactly return an integer and so be different from the result of floor().
If you want perfect results, I'd recommend simply parsing the string directly as abhishekm71 suggested at the start.