Share
Explore BrainMass

working with 2d arrays and functions

I'm to write a program to do calculations with a 2-d array. The following functions are to be developed to support a new development initiated by a local Multi-Optimal-Dimension Company (MAD COMP). Your program should handle any two dimensional array up to 100 by 100. (Dimension your array 100 by 100) You will need two arrays in your program for some of the functions below. The user will supply you with the dimensions at the time your program starts running. If the user gives you as input 5 and 10, then you are to process an array that is 5 rows and 10 columns, which is part of the 100 by 100 array you defined in your program. If the user gives you 25 by 75, then you have an array 25 rows and 75 cols which is part of the 100 by 100 array you defined in your program. You will not have multiple arrays with different dimensions. Your two arrays in your code will be the same size.
(I will supply you a pseudo main program to test you code with.).

You are to development the following functions to support this effort. Write a function for each of the following actions.

Add any two rows together, place results in the second argument (second row)
Subtract any two rows, (second row from first row )
place results in the second argument.
Add any two columns together, place results in the second argument.
Subtract any two columns, (second col form first col.)
place results in the second argument.
Copy one array into the other array: second argument.
Find the largest number in any row.
Find the largest number in any column.
Find the smallest number in any row.
Find the smallest number in any column.
Replace any element in the array with a new value
Ex call: Replace(array, r, c, newvalue)
Print out the array, one row per line. (yes for my test, a row will fit on one line.)
Put a blank between your values.

Example function: AddRow( array, firstrow, secondrow) or AddRow( myAry, 3,7)

I've written a program so far to let the user input the dimensions of the the 1st array (I named it ARRAYL and it's dimensions ROWSL and COLML; ARRAYB, ROWSB, and COLMB are for the 100x100 array.), as well as the subtraction/addition of rows and columns, the replacing of array values, the copying the 1st array content into 100x100 array, and the print array function. The problem is when I build the program, it literally gives me 30 errors such as

Line Message
9 expected ',' or '...' before numeric constant
42-48 can't convert 'double (*)[100]' to int (*)[100] for argument '1' to (whatever name I gave to the functions)

You'll have to copy and build my code from the 2dstuff text file to see what I mean.
Any corrections to my program will be appreciated. God Bless.

Attachments

Solution Preview

Dear Student,
I have corrected the code and now compiles fine.
Following were done,
1) Function arguments and function variables need to match
eg. Int in function arguments/parameters must match Int temp1 in function, or both need ...

Solution Summary

The expert examines working with 2d arrays and functions.

$2.19