Uploaded by gawiya6051

evidence.docx.Dev Ramodhine

advertisement
Dev Ramodhine
Grade 13 sc2
Qu1.(a)
Sub Main()
Dim position As Integer
Dim currentdata As Integer
Dim dataArray(6) As Integer
dataArray(0) = 6
dataArray(1) = 1
dataArray(2) = 15
dataArray(3) = 12
dataArray(4) = 5
dataArray(5) = 6
dataArray(6) = 9
Console.WriteLine("unsorted array ")
For i = 0 To 6
Console.WriteLine(dataArray(i))
Next
For x = 0 To 6
currentdata = dataArray(x)
position = x
While (position > 0 AndAlso dataArray(position - 1) > currentdata)
dataArray(position) = dataArray(position - 1)
position = position - 1
End While
dataArray(position) = currentdata
Next
Console.WriteLine("sorted array")
For i = 0 To 6
Console.WriteLine(dataArray(i))
Next
Console.ReadKey()
End Sub
End Module
1.(C)
\
1.d(i)
1.d(ii)
Module Module1
Sub Main()
Dim found As Boolean
Dim searchvalue As Integer
found = False
Console.WriteLine("enter search value")
searchvalue = Console.ReadLine()
For i = 0 To 6
If dataArray(i) = searchvalue Then
found = True
End If
Next
If found = True Then
Console.WriteLine("item found")
ElseIf found = False Then
Console.WriteLine("item not found")
End If
Console.ReadKey()
End Sub
End Module
Download