Finding Transpose of a Metrics

Problem Statement
Scan a metrics from user then
design an another metrics which is transpose to given metrics

#include<stdio.h>
#define max 5
void transpose(int a[][max],int Ta[][max],int r,int t);
int main()
{
  int i,j,r,t,a[max][max],Ta[max][max];
  printf("enter the dimntion of metrics \n");
  scanf("%d %d",&r,&t);
  printf("enter the metrics \n");
  for(i=0;i<r;i++)
    {
      for(j=0;j<t;j++)
{
 scanf("%d",&a[i][j]);
}
    }
  printf("the metrics is read as \n");
  for(i=0;i<r;i++)
    {
      for(j=0;j<t;j++)
{
 printf("%d ",a[i][j]);
}
      printf("\n");
    }
  transpose(a,Ta,r,t);
  printf("the transpose metrics is \n");
  for(i=0;i<t;i++)
    {
      for(j=0;j<r;j++)
{
 printf("%d ",Ta[i][j]);
}
      printf("\n");
    }

  return 0;
}
void transpose(int a[][max],int Ta[][max],int r,int t)
{
  int i,j;
  for(i=0;i<r;i++)
    {
      for(j=0;j<t;j++)
{
 Ta[j][i]=a[i][j];
}
    }
  return ;
}

No comments:

Post a Comment