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
Write an algorithm for multiplication of two sparse matrices using Linked Lists.


Read the scenario (Pickerings Properties). (a) List the functions of the system, as perceived by an external user. (b) List the external entities. Note that because we are mo

3. A function to convert a complex number in algebraic form to a complex number in phasor form

since the gregorian calendar was introduced in 1752,a leap year occurs every 4 years.you are to write a pseudo code to find out whether a year is a leap year.your progrm should dis

What is a linear array? An array is a way to reference a series of memory locations using the similar name. Every memory location is shown by an array element. An  array elemen

What are the structures used in file-system implementation? Several on-disk and in-memory structures are used to execute a file system a. On-disk structure include P

Q. Using array to execute the queue structure, write down an algorithm/program to (i) Insert an element in the queue. (ii) Delete an element from the queue.

Program: Program segment for insertion of an element into the queue add(int value) { struct queue *new; new = (struct queue*)malloc(sizeof(queue)); new->value = val

Write steps for algorithm for In-order Traversal This process when implemented iteratively also needs a stack and a Boolean to prevent the execution from traversing any portion