answersLogoWhite

0


Best Answer

Identification division.

Program-id.

Environment division.

Data division.

Working-storage section.

01 array.

02 x occurs 4 times.

03 y occurs 4 times.

04 a pic 9(2).

04 b pic 9(2).

04 c pic 9(3).

77 m pic 9.

77 n pic 9.

77 i pic 9.

77 j pic 9.

77 e pic 9.

77 p pic zz9.

Procedure division.

Main-para.

Display " enter the order of the matrices ".

Accept m.

Accept n.

Compute e = m * n.

Move 2 to lin.

Move 3 to col.

Display " enter " e " numbers for first matrix ".

Perform x-para varying i from 1 by 1 until i > m

after j from 1 by 1 until j > n.

Display " enter " e " numbers for second matrix ".

Perform y-para varying i from 1 by 1 until i > m

after j from 1 by 1 until j > n.

Perform c-para varying i from 1 by 1 until i > m

after j from 1 by 1 until j > n.

Display ( 1 , 1 ) erase.

Display " the sum of the two matrices is ".

Perform d-para varying i from 1 by 1 until i > m

after j from 1 by 1 until j > n.

Stop run.

X-para.

Accept a( i , j ).

Y-para.

Accept b( i , j ).

C-para.

Compute c( i , j ) = a( i , j ) + b( i , j ).

D-para.

Move c( i , j ) to p.

Display ( lin , col ) p.

Compute col = col + 3.

If ( j = n )

compute lin = lin + 1

move 3 to col.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a COBOL program to add 2 matrices?
Write your answer...
Submit
Still have questions?
magnify glass
imp