Hi there,
I am writing a program that is taking a number and finding its cube roots and then prints out whether the result is an odd or an even number. I have written the following code but for some reasons it is not giving me the right answer. Could you please help me with this.
#include<math.h>
#include <cmath>
#include <stdio.h>
int main()
{
double NbSites=216;
double numofsites = pow(NbSites,1./3.);
printf ("\n %f", numofsites);
printf ("\n %f", fmod(numofsites,2));
if ( fmod(numofsites,2) == 0) printf(" Even Lattice \n");
else printf (" Odd Lattice \n");
}
Any suggestion is very much appreciated.