Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are to write a C++ program that will perform calculations with a 2-D array.

ID: 640980 • Letter: Y

Question

You are to write a C++ program that will perform calculations with a 2-D array. Your program should handle 2-D 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.

                                Get function that returns one value from the array get(ary,r,c).

                                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)

Supplied Psuedo Main Program:

Restrictions: You must read in the dimension of the array. You can not have any code in your main program that has the [] syntax. Your declaration for the array in the main program can have [] and only there. Any and all array manipulations must be done in the functions given earlier. This also includes any new functions you decide to add to the program, ie the new functions cannot have [] syntax in them, just the functions stipulated in the program specifications.

For the following, do the operations in the order given below.

Read in the size of the array to be the following:

         Rows: 15, Columns: 15   Must be read in and not defined or hard coded in your program.

    Commands below for 1 through 10 is for FirstAry

1. Fill the array with the value 1 to 12 on the first row, 13 to 24
         on the second row etc for all 10 rows.  

Hint: This would look something like the following:

   i=0;

   for ( r=0; r<maxr; i++)

     for ( c=0; c< maxc; c++)

          Replace( ary, r, c, i++);               this fills the array

2 print FirstAry

3. Add: row 4 = row 2 + row 4

4. Add:   col 5 = col 5 + col 11

5. print FirstAry

9. Subtract the sum of row 1 and row 3 from row 7, results in row 7

10. Subtract from col 12 col 9, put results in col 12

11. print FirstAry

14. Find the largest value in FirstAry on row 10

15. Find the smallest value in FirstAry on col 5 and col 9.
                The one smallest value for both columns.

16. Fill row 4 of FirstAry with three time its column position.
                      3*col 0 = 0,    3* col 1 = 3,    3*col 2 = 6 etc. for each column.

17. Add rows 2, 3, 4 to row 7 of FirstAry

18. print FirstAry

19. Subtract col 3 and col 6 from col 12 of FirstAry

20. print FirstAry

Run your program again with a new main program to do the following.

New array dimension

1. Set up an array with 7 rows and 6 cols.

2. Fill array row 0 with 10 20 ..60

3. Fill array row 1 with 10 20 .. 60

   for all rows

4. print array

Explanation / Answer

#include #include #include class array { int **p,row,col; public: void getdata(void); friend void rowadd(array &); friend void rowsub(array &); friend void coladd(array &); friend void colsub(array &); friend void rowlrg(array &); friend void collrg(array &); friend void rowsml(array &); friend void colsml(array &); friend void rep(array &); friend void copyarr(array &,array &); void display(void); }; void array :: getdata(void) { clrscr(); coutrow; p=newint *[row]; coutcol; cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote