Module MaxMin Sub Main() Dim n, i, min, max As Integer Console.Write("Enter the number of Elements: ") n = CInt(Console.ReadLine()) Dim arr(n) As Integer For i = 0 To n - 1 Console.Write("Enter the " & (i + 1).ToString & "th element: ") arr(i) = CInt(Console.ReadLine()) Next Console.WriteLine("Array Contains...") For i = 0 To n - 1 Console.Write(arr(i) & " ") Next min = arr(0) max = arr(0) For i = 0 To n - 1 If arr(i) < min Then min = arr(i) End If Next For i = 0 To n - 1 If arr(i) > max Then max = arr(i) End If Next Console.WriteLine() Console.WriteLine("Minimum=" & min) Console.WriteLine("Maximum=" & max) Console.ReadLine() 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
Find Maximum and Minimum from an Array
Subscribe to:
Post Comments (Atom)
Imports System.Console
ReplyDeleteModule Module1
Sub Main()
Dim x As Integer
WriteLine("Enter the size of element")
x = ReadLine()
Dim array(x), i, max, min As Integer
WriteLine("Enter " & x & " Element")
For i = 0 To x - 1
Write("Element " & i + 1 & " : ")
array(i) = ReadLine()
Next
max = array(0)
min = array(0)
For i = 0 To x - 1
If array(i) > max Then
max = array(i)
End If
If array(i) < min Then
min = array(i)
End If
Next
WriteLine("The Maximum number from inserted elements is: " & max)
WriteLine("The Minimum number from inserted elements is: " & min)
ReadLine()
End Sub
End Module
very informative blog and useful article thank you for sharing with us , keep posting learn
ReplyDeletemore about Dot net
.NET Online Course