0% found this document useful (0 votes)
21 views3 pages

Reverse The Given String July 10, 2014

The document describes a program to reverse a given string in Visual Basic.NET. It includes the aim, procedure, coding, and output of the program. The program takes a string as input, stores it in an array, and uses a for-each and while loop to iterate through the array backwards, storing each character in a reversed string which is then output. The output shows the program successfully reverses the sample input string "reverse" to produce "esrever".

Uploaded by

Amutha Arun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views3 pages

Reverse The Given String July 10, 2014

The document describes a program to reverse a given string in Visual Basic.NET. It includes the aim, procedure, coding, and output of the program. The program takes a string as input, stores it in an array, and uses a for-each and while loop to iterate through the array backwards, storing each character in a reversed string which is then output. The output shows the program successfully reverses the sample input string "reverse" to produce "esrever".

Uploaded by

Amutha Arun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

7.

REVERSE THE GIVEN STRING

July 10, 2014

Aim:
~~~~
To write a program to perform reverses the given string using vb.net.
Procedure:
~~~~~~~~~
Step1: Start the program in the Microsoft Visual Studio 2010.
Step2: File->new->project Select the project type as visual basic and select
the visual studio installed template as console application.
Step3: Choose a Name, Location and Solution name.
Step4: Declare the variables get an input string as str and assign an i variable as 0.
Step5: Using for Each loop to assign a=str and increment a k values as 1.
Step6: Using while loop to check the condition as i>0.
Step7: Finally the output is stored in b.
Step8: End of the program.

12PA01

Page 20

7. REVERSE THE GIVEN STRING

July 10, 2014

Coding:
~~~~~~
Module Module1
Sub Main()
Dim str As String
Dim a(20), b(20) As Char
Dim i, k As Integer
Console.WriteLine("Reverse the string")
Console.WriteLine("****************")
Console.WriteLine("Input")
Console.WriteLine("~~~~")
Console.WriteLine("Enter the string :")
str = Console.ReadLine()
i=0
For Each element As Char In str
a = str
i=i+1
Next
k=0
While i > 0
i=i-1
b(k) = a(i)
k=k+1
End While
Console.WriteLine("Output")
Console.WriteLine("~~~~~~")
Console.WriteLine(b)
Console.ReadKey()
End Sub
End Module

12PA01

Page 21

7. REVERSE THE GIVEN STRING

July 10, 2014

Output:
~~~~~~
Reverse the string
****************
Input
~~~~
Enter the string :
reverse
Output
~~~~~~
esrever

Result:
******
Thus the reverse the given string program was successfully performed.

12PA01

Page 22

You might also like