Reverse the input number and print it


Module Module1
Sub main()
'declaring the datatypes
Dim reverse, temp As Integer
Dim num As Single

'input the number to be reversed
Console.WriteLine("Enter the number to be reversed")
num = Console.ReadLine

temp = 0
reverse = 0

'start of the while loop
While num <> 0
temp = num Mod 10
reverse = reverse * 10 + temp
num = num \ 10
End While

'printing the number after reversing
Console.WriteLine(reverse)

Console.ReadLine() ' this line of code holds the screen so that you can see the output
End Sub
End Module

Comments

Popular posts from this blog

Program to extract vowel from the input string

Check whether the input number is arm-strong or not

Print the factorial value of an input number