Posts

Showing posts from September 27, 2017

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