the program accepts matrix like input amp prints


/* The program accepts matrix like input & prints the 3-tuple representation of it*/

#include

void main()

{

int a[5][5],rows,columns,i,j;

printf("enter the order of the matrix. The order must be less than 5 × 5:\n");

scanf("%d %d",&rows,&columns);

printf("Enter elements of the matrix:\n");

for(i=0;i

for(j=0;j

{

 scanf("%d",&a[i][j]);

}

printf("The 3-tuple representation of  any matrix is:\n");

for(i=0;i

for(j=0;j

{

if (a[i][j]!=0)

{

}

Output:

printf("%d    %d       %d\n", (i+1),(j+1),a[i][j]);

}

}

Enter the order of the matrix. The order must be less than 5 × 5:

3 3

Enter the elements of the matrix:

1 2 3

0 1 0

0 0 4

The 3-tuple representation of the matrix is:

1

1

1

1

2

2

1

3

3

2

2

1

3

3

4

Initially the program prompted for the order of the input matrix along a warning that the order must not be greater than 5 × 5. After accepting order, this prompts for the elements of the matrix. After accepting the matrix, this checks each element of the matrix for a non zero. If the element is non zero, then this prints the row number & column number of that element along its value.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: the program accepts matrix like input amp prints
Reference No:- TGS0262421

Expected delivery within 24 Hours