How to find a max number from an integer

Can somebody please help me out !
i want to make program in which we input a integer and it gives output
the maximum number.
e.g if i give 1232 it will output the 3.
i have to make it without using any array or stack..
- keep track of the maximum number 'm'
- start 'm' at zero
- check each digit. If the digit is greater than 'm', them 'm' = that digit
- once all digits have been checked, output 'm'

Hints:
- The % operator returns the remainder after division (20 % 7 = 6)
- Use % and / to get one digit at a time
- It's OK to change the original input number in this process.
hey i have the same problem
and was able to get the code for the remainder
but how do i compare that to the other remainders ?

int n, r ;
cout << "Enter Any Number"<< endl;
cin >> n;
r = n%10;
cout << r;
Hint: Try a third variable for the right-hand-side of your % that increases by powers of ten.

-Albatross
Topic archived. No new replies allowed.