HOW to check if integer ends in zero using modulus %
Hi, my problem is as follows:
I have an array of ints, each integer has 5 digits.
How can I find out if these ints end with a zero (e.g 23450)?
I was told that I could use the modulus (%) operator.
But if I do something like:
1 2 3 4 5
|
int number =23450;
if ((number%2)==0)
{
//this would only tell me if the number is odd or even
}
|
thanks in advance
1 2 3
|
if ((number%10) == 0){
\\logically, if a number is divisible by ten, then it must end in a zero.
}
|
oh yes.
thanks
Topic archived. No new replies allowed.