Order of the matrix, Data Structure & Algorithms

/* 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.

Posted Date: 4/4/2013 6:35:20 AM | Location : United States







Related Discussions:- Order of the matrix, Assignment Help, Ask Question on Order of the matrix, Get Answer, Expert's Help, Order of the matrix Discussions

Write discussion on Order of the matrix
Your posts are moderated
Related Questions

Which data structure is used for implementing recursion Stack.

Program segment for All pairs shortest paths algorithm AllPairsShortestPaths(int N, Matrix C, Matrix P, Matrix D) { int i, j, k if i = j then C[i][j] = 0  for ( i =

Explain Backtracking The  principal idea is to construct solutions single component  at a time  and evaluate such  partially constructed candidates as follows. If a partiall

Illustrate an example of algorithm Consider that an algorithm is a sequence of steps, not a program. You might use the same algorithm in different programs, or express same alg

Circular Queues:- A more efficient queue representation is get by regarding the array Q(1:n) as circular. It becomes more convenient to declare the array as Q(O: n-1), when  re

Operation of Algorithm The following sequence of diagrams shows the operation of Dijkstra's Algorithm. The bold vertices show the vertex to which shortest path has been find ou

Determine YIQ Colour Model Whereas an RGB monitor requires separate signals for the red, green, and blue components of an image, a television monitor uses a single composite si


Write down any four applications of the queues.                                                            Ans. A pp li cation of Queue is given below (i)  Queue is