Posts

Program to extract vowel from the input string

Module Module1 Sub Main() 'Progrm to extract the vowels from the input string 'declaring the variables Dim entry, temp, vowels As String Dim index As Integer vowels = "" Console.WriteLine("Enter the string to extract vowels from it") entry = Console.ReadLine() For index = 1 To entry.Length temp = UCase(Mid(entry, index, 1)) If temp = "A" Or temp = "E" Or temp = "I" Or temp = "O" Or temp = "U" Then vowels = vowels & " " & temp End If Next Console.WriteLine("The vowels in the string :" & entry & " are:- ") Console.WriteLine(vowels) Console.ReadKey() End Sub End Module

Check whether the input number is prime or not

Module Module1 Sub Main() 'program to check whether the input number is a prime number or not 'decalring the variables Dim entry, count, index As Integer Console.WriteLine("Enter the number to check prime or not") entry = Console.ReadLine() For index = 1 To entry If entry Mod index = 0 Then count = count + 1 End If Next If count = 2 Then Console.WriteLine(entry & " is a prime number") Else Console.WriteLine(entry & " is not a prime number") End If Console.ReadKey() End Sub End Module

Check whether the input number is arm-strong or not

Module Module1 Sub Main() 'Program to check whether the input number is armstrong or not 'decalring the variables Dim entry, num, check, temp As Integer Console.WriteLine("Enter the number to check whether the number is arm strong or not") entry = Console.ReadLine() num = entry While num <> 0 temp = num Mod 10 check = check + temp ^ 3 num = num \ 10 End While If entry = check Then Console.WriteLine("The number is a armstrong number") Else Console.WriteLine("The number is not a palindrome number") End If Console.ReadKey() End Sub End Module

Program to generate prime numbers

Module Module1 Sub Main() 'Program to generate prime numbers 'declaring the variables Dim num, count, inner_index, index As Integer Console.WriteLine("Enter number to generate prime number to that range (e.g. 10,20,50 etc.)") num = Console.ReadLine() Console.WriteLine("The prime numbers are") For index = 1 To num count = 0 For inner_index = 1 To index If index Mod inner_index = 0 Then count = count + 1 End If Next If count = 2 Then Console.Write(index & " ") End If Next Console.ReadKey() End Sub End Module

Program to check the input number is palindrome or not

Module Module1 Sub Main() 'program to check whether the input number is palindrome or not 'declaring the variables Dim entry, num, temp, reverse As Integer Console.WriteLine("Enter the number youu want check as Palidrome or not") entry = Console.ReadLine() num = entry While num <> 0 temp = num Mod 10 reverse = reverse * 10 + temp num = num \ 10 End While Console.WriteLine(reverse) If entry = reverse Then Console.WriteLine("The input number is a palindrome number") Else Console.WriteLine("The input number is not a palindrome number") End If Console.ReadKey() End Sub End Module

Reverse the Input string

Module Module1 Sub Main() 'program to reverse the input string 'declaring the variables Dim Index As Integer Dim temp, reverse, inputed_string As String Console.WriteLine("Enter the String") inputed_string = Console.ReadLine() reverse = "" Index = Len(inputed_string) While Index <> 0 temp = Mid(inputed_string, Index, 1) reverse = reverse & temp Index = Index - 1 End While Console.WriteLine("The reversed string is =" & " " & reverse) Console.ReadKey() End Sub End Module

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