check if float has decimals c++
#include <iostream>
#include <cmath>
int main() {
float num;
std::cout << "Enter a float number: ";
std::cin >> num;
float fractionalPart = num - std::floor(num);
if (fractionalPart > 0) {
std::cout << "The float number has decimals." << std::endl;
} else {
std::cout << "The float number does not have decimals." << std::endl;
}
return 0;
}