30. Write a VB program to find whether given matrix is symmetric or not.


Private Sub cmdAdd_Click()
Dim i, j, r1, c2 As Integer
Dim a(), b() As Integer
r1 = Val(InputBox(“Enter rows”))
c1 = Val(InputBox(“Enter columns”))
ReDim a(r1, c1)
Text1.Text = “First Matrix is :” & vbNewLine
For i = 1 To r1
For j = 1 To c1
a(i, j) = Val(InputBox(“Enter Elements”))
Text1.Text = Text1.Text & a(i, j) & ” ”
Next
Text1.Text = Text1.Text & vbNewLine
Next

ReDim b(r1, c1)
Text1.Text = Text1.Text & “Transpose of Matrix is :” & vbNewLine
For i = 1 To r1
For j = 1 To c1
b(i, j) = a(j, i)
Text1.Text = Text1.Text & b(i, j) & ” ”
Next
Text1.Text = Text1.Text & vbNewLine
Next

For i = 1 To r1
For j = 1 To c1
If a(i, j) = b(i, j) Then
flag = 1
Else
flag = 0
End If
Next
Next
If flag = 1 Then
Text1.Text = Text1.Text & “Given Matrix is Symmetric”
Else
Text1.Text = Text1.Text & “Given Matrix is not Symmetric”
End If
End Sub

Private Sub cmdClear_Click()
Text1.Text = “”
End Sub

Private Sub cmdExit_Click()
Unload Me
End Sub

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s