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

Write a C program (not C++) that calls a function to multiply a matrix (two dime

ID: 3842426 • Letter: W

Question

Write a C program (not C++) that calls a function to multiply a matrix (two dimensional array).

The main program should ask the user to enter an integer that will be used as the matrix “adder” and then call the function. The function should perform a matrix increment (every element of the array is incremented by the same value) and assign the result to another array. The function should be flexible enough to work with any array size and “adder”, communicated to the function from the main function.

After the function call, the main program should print the array with the initial values followed by the multiplied values as shown below.

Use as many variables and arrays as needed. When initializing the array, use the initial values shown in the output.

Provide restriction so that the original array passed to it cannot be modified by the function.

Expected input / output.

Enter adder: 2

Initial values

5    2    7  

1    6    3

After adding by 2

7   4   9  

3   8   5

Explanation / Answer

Ans.

#include <iostream>
using namespace std;

int main() {
   // your code goes here
   int n, a[2][3];
   cout << "Enter adder: ";
   cin >> n;
   cout << "Initial Values: ";
   for (int i = 0; i < 2; i++)
   {
       for (int j = 0; j < 3; j++)
       {
           cin>>a[i][j];
       }
   }
   cout<<" ";
   for (int i = 0; i < 2; i++)
   {
       for (int j = 0; j < 3; j++)
       {
           cout<<a[i][j] + n<< " ";
       }
       cout<<" ";
   }
   return 0;
}

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