0
C++ program to read (X) and then disting uish either X is an odd or even using (double)
4 Answers
+ 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?