Write a C program to read the values of a 6 x 6 2D array from a file, and then produce an output file that contains the transpose of the array. Array values are decimal. The input and output files contain one array row on each text line

Respuesta :

Answer:

Explanation:

#include <stdio.h>

int main()

{

   int arr[5][5], trans [5][5], i, j;

   // Entering elements to the matrix

   printf("\nEnter matrix elements:\n");

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

       for (j = 0; j < 6; ++j) {

           printf("Enter element a%d%d: ", i + 1, j + 1);

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

       }

 

   printf("\nThe given input matrix is: \n");

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

       for (j = 0; j < 6; ++j) {

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

           if (j == 5)

               printf("\n");

       }

   // Transpose

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

       for (j = 0; j < 6; ++j) {

           trans[j][i] = a[i][j];

       }

   printf("\nThe output transpose of the matrix:\n");

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

       for (j = 0; j < 6; ++j) {

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

           if (j == 5)

               printf("\n");

       }

   return 0;

}