VB.Net Program to find the Number Palindrome or not
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
Module Module1 Sub Main() Dim num As Integer, remainder As Integer, sum As Integer = 0, temp As Integer Console.WriteLine("*** www.ProgrammingPosts.blogspot.com ***") Console.WriteLine(vbLf & " >>>> To Find a Number is Palindrome or not <<<< ") Console.Write(vbLf & " Enter a number: ") num = Convert.ToInt32(Console.ReadLine()) temp = num While Convert.ToBoolean(num) remainder = num Mod 10 'for getting remainder by dividing with 10 num = num / 10 'for getting quotient by dividing with 10 'multiplying the sum with 10 and adding remainder sum = sum * 10 + remainder End While Console.WriteLine(vbLf & " The Reversed Number is: {0} " & vbLf, sum) If temp = sum Then 'checking whether the reversed number is equal to entered number Console.WriteLine(vbLf & " The given Number is Palindrome ") Else Console.WriteLine(vbLf & " The given Number is not a palindrome ") End If Console.ReadLine() End Sub End Module |
Sample Output :