Module BSFun Sub Main() Console.WriteLine("Bubble Sorting using Function") Console.WriteLine() Dim n, i As Integer Console.Write("Enter Number of Elements: ") n = CInt(Console.ReadLine) Dim arr(n) As Integer Console.WriteLine() For i = 0 To n - 1 Console.Write("Enter Element(" & (i + 1) & "): ") arr(i) = CInt(Console.ReadLine) Next Console.WriteLine() Console.WriteLine("Before Sorting") Console.WriteLine() For i = 0 To n - 1 Console.WriteLine("Element in (" & i & "): " & arr(i)) Next sort_array(arr, n) Console.WriteLine("Sorted Array") Console.WriteLine() For i = 0 To n - 1 Console.WriteLine("Element in (" & i & "): " & arr(i)) Next Console.ReadLine() End Sub Sub sort_array(ByVal x() As Integer, ByVal y As Integer) Dim i, j, t As Integer For i = 0 To y - 1 For j = i + 1 To y - 1 If x(i) > x(j) Then t = x(i) x(i) = x(j) x(j) = t End If Next Next End Sub End Module
Visual Basic dot net VB.net programming microsoft .net framework object oriented language network enabled technology visual basic 2005 IDE integrated development environment console application microsoft cre common runtime environment
Bubble Sorting Using Function
Subscribe to:
Post Comments (Atom)
Thanks Alot!!
ReplyDeleteThese Codes helped me alot