Home » Sometech » WAP to find transpose of a squaRE matrix.

WAP to find transpose of a squaRE matrix.

#include <stdio.h>

#include<conio.h>

#define S 5

void main()

{

   int i,j,order,temp;

    int A[S][S];

clrscr();

printf(“Enter order of the square matrix <=5 ? “);

scanf(“%d”,&order);

printf(“Enter matrix of order %d * %d : \n”,order,order);

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

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

  scanf(“%d”, &A[i][j]);

 

printf(“\nGiven matrix is:\n”);

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

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

   printf(“%2d”, A[i][j]);

    printf(“\n”);

 }

 

/*transpose*/

for (i = 0; i < order-1; i++)

{ for (j = i+1; j < order; j++)

 {

 

 temp=A[i][j];

   A[i][j]=A[j][i];

    A[j][i]=temp;

 }

}

 

 

printf(“\nTranspose of matrix : \n”);

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

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

     printf(“%2d”, A[i][j]);

    printf(“\n”);

 }

getch();

}

Advertisements

SoME Tech

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

%d bloggers like this: