void transpose_matrices(int a[][2],int result[][2])
     int i,j,temp;
     for (i = 0; i < 2; i++)
                  for (j = i+1; j < 2; j++)
                        temp = a[i][j];
                        a[i][j] = a[j][i];
                        a[j][i] = temp;

it would be very helpful if someone guide with this transpose function.
i have done the above code. pls correct me.

Re: matrix transpose 80 80

first, that function needs to know the size of each matrix -- don't leave any dimensions unspecified as you did. Your function appears to be derived from the bubble sort -- toss it in the bit bin because it will not work. A transpose function does not need a temp variable nor does it swap variables. You need two matrixes where the number of rows and columns in the result matrix are the opposite of the number in the original source matrix. Thus, you can't leave any of the dimensions unspecified.

If you are unsure exactly what transpore is, read this tutorial. After you understand that, it should be fairly simple to write the program.

Re: matrix transpose 80 80
Given the matrix array:

    char matrix[][4] = { 'a', 'b', 'c', 'd',
                         'e', 'f', 'g', 'h',
                         'i', 'j', 'k', 'l' }; 
Transpose means the rows becoming colums and the colums becoming rows.
Calling the first element of the first dimesion subscrit will produce
the first transpose row:

    matrix[0][0]    'a'
    matrix[1][0]    'e'
    matrix[2][0]    'i'

Calling the second element will give us:
    matrix[0][1]    'b'
    matrix[1][1]    'f'
    matrix[2][1]    'j'

The third element of each dimesion is:
    matrix[0][2]    'c'
    matrix[1][2]    'g'
    matrix[2][2]    'k'

And finally the last one:
    matrix[0][3]    'd'
    matrix[1][3]    'h'
    matrix[2][3]    'l'

All this can be accomplished by the use of two for loops

    for (colum = 0; colum < reach end colum; colum++)
        for (row = 0; row < reach end row; row++)
            printf ("%c ", matrix[row][colum]);
        putchar ('\n');
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.