Write a Vb.net program to check whether entered string is palindrome or not.

Program:-

 Module slip1

    Sub main()

        Dim n, newstr As String

        Console.Write("Enter String: ")

        n = Console.ReadLine()

        newstr = ""

        For i As Integer = 0 To n.Length() - 1

            newstr = n(i) + newstr

        Next

        If n = newstr Then

            Console.WriteLine((CStr(newstr) + " string is palindrome "))

        Else

            Console.WriteLine((CStr(n) + " string is not palindrome "))

        End If

        Console.ReadKey()

    End Sub

End Module

Output:-


Design:-

    1) Open visual basic 
    2) Add Module 
    3) Save it as slip1.vb 
    4) Select Startup form as slip1.vb and Select Application type as Console Application save this and run this program.
   
Theory:-

    Dim - dim is used to declare the variables in vb.net.
    Console.Write() - It is used to write on the console applications.
    Console.Read() - It is used to read from the console applications.
    Console.ReadKey() - It is used to hold the screen.
    CStr - It is used to convert into a string.


0 Comments