VB.Net Program to Print Reverse of a Number
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
Module Module1 Sub Main() Dim num As Integer, remainder As Integer, sum As Integer = 0, rev As Integer Console.WriteLine("*** www.ProgrammingPosts.blogspot.com ***") Console.WriteLine(vbLf & " >>> VB.NET Program To Find Reverse Of a Number <<<") Console.Write(vbLf & " Enter a number: ") num = Convert.ToInt32(Console.ReadLine()) While Convert.ToBoolean(num) remainder = num Mod 10 'for getting remainder by dividing with 10 num = num / 10 'symbol is for Integer Division in vb.net 'for getting quotient by dividing with 10 sum = sum * 10 + remainder End While rev = sum Console.WriteLine(vbLf & " The Reversed Number is: {0} " & vbLf , rev) Console.ReadLine() End Sub End Module |
Sample Output: