Purchase Solution

working with 2d arrays and functions

Not what you're looking for?

Ask Custom Question

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.

Purchase this Solution

Solution Summary

The expert examines working with 2d arrays and functions.

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 provided by:
Education
  • BSc (Hons), University of Colombo - Sri Lanka
  • MEngSc, University of Melbourne
  • Certificate IV in Training & Assessment , Australian Business Council
Recent Feedback
  • "Thank you!"
  • "Thank you."
  • "Thanks a lot for you help and support"
  • "Sorry about the late payment but the assignment was sufficient and appreciated. Good work"
  • "Great description! Thank you for your quick response."
Purchase this Solution


Free BrainMass Quizzes
C++ Operators

This quiz tests a student's knowledge about C++ operators.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

C# variables and classes

This quiz contains questions about C# classes and variables.