Let Us C (Chapter 8 : Arrays) : Program-11

(k) Write a program to obtain transpose of a 4 x 4 matrix. The transpose of a matrix is obtained by exchanging the elements of each row with the elements of the corresponding column

let us c chapter 8 arrays problem 11


// Let Us C (Chapter 8 : Arrays) : Program-11 
/* Write a program to obtain transpose of a 4 x 4 matrix. The transpose of a matrix is obtained 
by exchanging the elements of each row with the elements of the corresponding column. */

#include<stdio.h>
long int Arr[4][4];
unsigned int i,j;
void main()
{
	clrscr();
	for(i=0;i<4;i++)
	{
		for(j=0;j<4;j++)
		{
			printf("Enter Arr[%d][%d] element: ",i,j);
			scanf("%ld",&Arr[i][j]);
		}
	}
	printf("\nMatrix is :\n");
	for(i=0;i<4;i++)
	{
		for(j=0;j<4;j++)
		{
			printf("%0.2ld ",Arr[i][j]);
		}
		printf("\n");
	}
	printf("\nTranspose Matrix is: \n");
	for(i=0;i<4;i++)
	{
		for(j=0;j<4;j++)
		{
			printf("%0.2ld ",Arr[j][i]);
		}
		printf("\n");
	}
}
OUTPUT

let us c chapter 8 arrays problem 11 Output


Comments

Popular posts from this blog

Chapter 5 : Functions & Pointers (Let us C)

Let Us C (Chapter 8 : Arrays) : Program-9

Chapter 3: The Loop Control Structure (Let Us C)