Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

An array A of size 5 x 5. a. Read in the array and write it out in row form (one

ID: 3824484 • Letter: A

Question

An array A of size 5 x 5. a. Read in the array and write it out in row form (one row per line then print each column on one line, i.e., Au, A 21, JI Asi on one linc then A A An A on the second line, etc. b. Calculatc the sum of the elements in the third row. c. Find the largest value in the first column. d- create a linear array B consisting of five elements initialized to zero. Cal- culate the sum of each column of A, storing the result in the corresponding column position of B. e. Add corresponding elements of rows 2 and 3 of the array A, storing results in row 3; that is, A(3,1) A(3,1) A(2,1), etc. f. Interchange column 3 and column 4. g. compute the sum of the entries of the main diagonal, i.e., All, Az, A h. Compute the sum of the entries of the secondary diagonal and determine the largest entry of that diagonal CThe secondary diagonal consists of cle- ments AIS, A2e, Au, Au2, Asm) i. Print the smallest element of the array A and its position in the array (row, column)

Explanation / Answer

h.

Module Module1

Sub Main()
Dim primerysum As Integer = 0, secondorysum As Integer = 0
Dim num(,) As Integer = {{1, 2, 3, 4, 5}, {2, 3, 1, 2, 3}, {3, 4, 5, 2, 3}, {3, 4, 2, 3, 4}, {4, 5, 3, 2, 2}}
Console.WriteLine("array of 5*5 ")
For i = 0 To 4
For j = 0 To 4
System.Console.Write(num(i, j))
Next j
Console.WriteLine()

Next i
Console.ReadKey()

Console.WriteLine()
For i = 0 To 4
secondorysum = secondorysum + num(i, 4 - i)
Next i
Console.WriteLine("Sum of secondary diagonal ")
Console.WriteLine(secondorysum)
Console.ReadKey()

End Sub


End Module

g.

Module Module1

Sub Main()
Dim primerysum As Integer = 0, secondorysum As Integer = 0
Dim num(,) As Integer = {{1, 2, 3, 4, 5}, {2, 3, 1, 2, 3}, {3, 4, 5, 2, 3}, {3, 4, 2, 3, 4}, {4, 5, 3, 2, 2}}
Console.WriteLine("array of 5*5 ")
For i = 0 To 4
For j = 0 To 4
System.Console.Write(num(i, j))
Next j
Console.WriteLine()

Next i
Console.ReadKey()

Console.WriteLine()
For i = 0 To 4
secondorysum = secondorysum + num(i, 4 - i)
Next i
Console.WriteLine("Sum of secondary diagonal ")
Console.WriteLine(secondorysum)
Console.ReadKey()


Console.WriteLine("Smallest element of aray")
Dim a(2, 2) As Integer
a(0, 0) = 22
a(0, 1) = 66
a(1, 0) = 9
a(1, 1) = 36


Console.WriteLine("array ")
For i = 0 To 1
For j = 0 To 1
System.Console.Write(a(i, j))
Next
Console.WriteLine()
Next i
Console.ReadKey()


Dim min As Integer
min = a(0, 0)
For i = 0 To 1
For j = 0 To 1
If a(i, j) < min Then
min = a(i, j)
End If
Next
Next
Console.Write("Smallest element ")
Console.WriteLine(min)
Console.ReadLine()


End Sub


End Module

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote