Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding 2 2-D arrays to make a third array 2

Status
Not open for further replies.

cjones

Technical User
Apr 7, 2001
22
0
0
US
Hello :)

I have an assignment that requires me to add together 2 small 2-D arrays making a 3rd array. I understand how to work with 1 2-D array but don't know how to add 2 arrays together. Any tips, web sites or etc. WOULD BE GREATLY APPRECIATED!

Christine
 
do you mean addition of 2 matrices?
or concat 2-d arrays making 1-d array?
 
Clarification--I need to write a program that will add the 2 arrays & put the answers in a 3rd array.

first[2][3] + second[2][3] = sum[2][3]

first (name of array)
16 18 23
54 91 11

second (name of array)
24 52 77
16 19 99

the above arrays added together will equal the array
sum
40 70 100
70 110 110

I know I will be using a function & a number of for statements.
 
You'll need 2 loops, for loops would be ideal, and 2 counters that keep track of the outer and inner indices as you iterate through the loops. The only calculations you will do will occur in the innermost loop.

I could just give you the code, but since this is a homework assignment I'm sure you wouldn't want us to deprive you of the learning experience. For more help, please submit your best attempt (the code).

Russ
bobbitts@hotmail.com
 
to cjones:

you'd better follow rbobbitt instruction,
i'll give you a bit hint

you know how to input an array?
the same structure of for loop but instead of inputing values, you just do the evaluation

regards,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top