Quote:
Originally Posted by chemr2 View Post
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
I have figured out the problem I think. In my code I had this
(x%5 == 0 && x%2 == 0)
Obviously 345555 is divisible by 5 but is not divisible by 2, 9000 900000 and all of those numbers are divisible by both. That is why the number was not passing through. I changed it to
if (x%5 == 0 || x%2 == 0)
now it can be either or.