How can I input a number for example 54503 and let the program go through all the numbers and check if there is an even number or not? I think it should be inside a loop, and the condition for if it's even should be %2 == 0, but I don't know what the condition of the loop should be?
First thing I would do is make sure that you take the input as a string. Then you would loop through the string based on it's length so:for(unsigned i = 0; i < Input.length(); ++i)//... and use "atoi()" or something similar with the element access operator to turn each character into an integer. Then you can do your modulous test on that for each element.
int n;
int m = n;
while(n > 0){
if( (n%10)%2 == 0) cout << "even digit!";
n/=10;
}
n%10 is the digit. It checks if digit is even, if it is even it outputs "even digit!". The loop goes through all the digits. Notice the n/=10; m is the unmodified original number. Please ask if you have more doubts.