Ticker

6/recent/ticker-posts

CPNM LAB PROGRAM-6

 

cpnm lab 6 programming made by ece the wonders ***THANK YOU***     
----------------------------------------------
6. Write a function for transposing a square matrix in place (in place means that you are not allowed to have full temporary matrix).
-------------------------------------------
PROGRAM :-

#include <stdio.h>

void transpose(int a[10][10],int n);

int main()

{  int i,j,n;
   int a[10][10];
  

  printf("ENTER THE ORDER OF MATRIX : ");
  scanf("%d",&n);
printf("--------------------------");

  printf("\nENTER THE MATRIX ELEMENTS:\n");
  

   for (i=0;i<n;i++)
{
   for (j=0;j<n;j++)
{
   printf("THE ELEMENT AT POSITION a[%d][%d]=",i,j);
  
   scanf("%d",&a[i][j]);
}

}
  transpose(a,n);

 for (i=0;i<n;i++)
 for (j=0;j<n;j++)
{
 printf("%d\t",a[i][j]);
}
 printf("\n");
}
printf("--------------------------------------");
printf("\nThe above matrix is transpose matrix\n");
printf("------------------------------------------------------------\n");
printf("this code is created by ECE⚡THE⚡WONDERS, HEMU😍THE😍SMART\n");
return 0;
}

void transpose (int a[10][10],int n)
{  
  int i,j;
  float temp;
 
 for (i=0;i<n-1;i++)
{
 for (j=i+1;j<n;j++)
{
  temp=a[i][j];
   a[i][j]=a[j][i];
   a[j][i]=temp;
}
}
}

OUTPUT :-


-:DON'T TRY TO COPY AND PASTE THE CODE .SELECTION OF CODE IS DISABLED:-

Post a Comment

0 Comments