// Problem 7: inputMatrix (10 points)// Ask the user for each element of the 3X3 matrix and store the elements in"matrixA[][]"// Display the matrix in the following form:// matrixA =// 1 2 3// 4 5 6// 7 8 9// The user may input any inetgers for matrix elements, not necessarily same asexample above.void inputMatrix(int matrixA[3][3]){}

Respuesta :

Answer:

Following are the program for the above question:

Explanation:

#include <stdio.h> //header file

void inputMatrix(int matrixA[3][3]) //inputmatrix function to take the inputs and display the outputs.

{

  int i,j; //declare the symbols.

//loop to take the inputs.

 for(i=0;i<3;i++)

  for(j=0;j<3;j++)

   scanf("%d",&matrixA[i][j]);

//loop to print the output

 for(i=0;i<3;i++)

 {

  for(j=0;j<3;j++)

   printf("%2d",matrixA[i][j]);

  printf("\t");

 }

}

int main() //main function

{

  int matrixA[3][3]; //matrix declaration.

inputMatrix(matrixA); //calling function.

   return 0;

}

Output:

  • The above code take the 9 inputs from the user and display the output as described question format.

Code Explanation:

  • There is one user-defined function that takes the double dimension array as the argument.
  • Then it takes the 9 value for the double dimension array.
  • Then it displays the value to the user in that format which is defined by the question.
ACCESS MORE
ACCESS MORE
ACCESS MORE
ACCESS MORE