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:
No comments:
Post a Comment
Thanks for your comments.
-Sameer