Saturday 30 November 2013

Reverse number logic using integer

Reverse number logic using integer :


        public static int reverseNumber(int i)
        {
            int temp = 0;
            while (i > 10)
            {
                int num = i % 10;
                temp = (temp * 10) + num;
                i = i / 10;
            }
            temp = (temp * 10) + i;

            return temp;

        }

No comments:

Post a Comment