Posts

Showing posts from June 22, 2017

Print the factorial value of an input number

Module Module1 Sub main() 'program to print the factorial value of a input number 'declaring the datatypes Dim num, factorial As Integer 'initializing the value of factorial factorial = 1 'entry of the number Console.WriteLine("Enter the number whose factorial value you want to be generated ") num = Console.ReadLine 'start of the while loop to calculate the factorial value of the input number While num <> 0 factorial = factorial * num num = num - 1 End While 'generating the output of the factorial value Console.WriteLine("The factorial value of the number you entered is " & factorial) Console.ReadLine() ' this line of code holds the screen so that you can see the output End Sub End Module

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