0
C++ program to read (X) and then disting uish either X is an odd or even using (double)
4 Respostas
+ 1
To calculate division remainder for floating point values, we can use fmod() from <cmath>
NOTE: Since fmod() returns a floating point value, you will need to cast the returned value into integer type before using the value in making decision, the fraction may bother you if you didn't.
http://www.cplusplus.com/reference/cmath/fmod/
+ 1
int x;
std::cin >> x;
if(x%2==0)
{
std::cout <<´´even´´;
}
else
{
std::cout <<´´odd´´;
}
0
Double num;
Cin>>num;
if(num%2==0)
{
cout<<´´even´´;
}
else
{
cout<<´´odd´´;
}
0
Error occurs because I used double
How I can solved?