In this post, here is the C#.Net code to get the reverse of a number. Getting Reverse of a string is quite easy using string functions but for a number it differs.
Here we will see how to get reverse of a number without using any built-in methods.
You can also use this method while checking whether the number is Palindrome.
If the input number and the reversed input number are same, then the number is said to be a Palindrome.
/// Method to get reverse of a number
/// <param name=”Num”>Number to be reversed</param>
/// <returns>reversed input number</returns>
public intReverseOfNum(int Num)
//for getting remainder by dividing with 10
//for getting quotient by dividing with 10
//multiplying the sum with 10 and adding remainder
RevNum = RevNum * 10 + rem;
Posts you may like :
>> VB.Net Code to get Reverse of a Number