Quote:

Originally Posted by **xpi0t0s**
Don't know why 345555 passes through, it is certainly divisible by 5. Compiler bug perhaps? What compiler are you using?

Did you try printing the number entered back on screen to check the variable contains the expected value?

Paste the following function into your code, call it, and let me know what the output was:

Code:

void go4e_43398()
{
int num[7]={3,7,15,20,345555,36,40};
for (int i=0; i<7; i++)
{
if (num[i]%5==0 || num[i]%2==0)
printf("%d is divisible by 2 or 5\n",num[i]);
}
printf("sizeof int=%d\n",sizeof(int));
}

Obviously this shouldn't say anything for 3 or 7, but the rest should print "is divisible by 2 or 5".

I am using Dev C++. I did print x after the cin>> and it was the same value so obviously there isn't a problem with that. After calling the function you gave me the results were:

15 is divisible by 2 or 5

20 is divisible by 2 or 5

345555 is divisible by 2 or 5 (hmmmmmm why is it working here?)

36 is divisible by 2 or 5

40 is divisible by 2 or 5

size of int =4