Wednesday, 6 February 2013

Write a c program to display the transpose of given 3 X 3 matrix



#include<stdio.h>
#include<conio.h>
  void main()
{
  int a[10][10],b[10][10],i,j;
  clrscr();
  printf("\nEnter the elements of matrix:");
  for(i=0;i<3;i++)
{
  for(j=0;j<3;j++)
{
  scanf("%d",&a[i][j]);
}
}
  printf("\nThe Transpose of matrix is:\n");
  for(i=0;i<3;i++)
{
  for(j=0;j<3;j++)
{
  b[i][j]=a[j][i];
  printf("\t%d\t",b[i][j]);
}
  printf("\n");
}
  getch();
}

//OUTPUT:
//Enter the elements of matrix:
    1 2 3 4 5 6 7 8 9
//The Transpose of matrix is:
    1 4 7
    2 5 8
    3 6 9

3 comments:

  1. Appreciation for nice Updates, I found something new and folks can get useful info about BEST ONLINE TRAINING

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Transpose of a matrix is similar to rotating a matrix by 90 degree. first row of matrix becomes first column and so on.

    ReplyDelete