Order of the matrix, Data Structure & Algorithms

Assignment Help:

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


Related Discussions:- Order of the matrix

Frequency count, what is frequency count with examble

what is frequency count with examble

How do you find the complexity of an algorithm, How do you find the complex...

How do you find the complexity of an algorithm?  Complexity of an algorithm is the measure of analysis of algorithm. Analyzing an algorithm means predicting the resources that

Bubble sort, In this sorting algorithm, multiple swapping occurs in one pas...

In this sorting algorithm, multiple swapping occurs in one pass. Smaller elements move or 'bubble' up to the top of the list, so the name given to the algorithm. In this method,

Sorting algorithms, Sorting is significant application activity. Several so...

Sorting is significant application activity. Several sorting algorithms are obtainable. But, each is efficient for a specific situation or a specific kind of data. The choice of a

What is a range - a structured type in ruby, Range: A Structured Type in Ru...

Range: A Structured Type in Ruby Ruby has a numerous structured types, comprising arrays, hashes, sets, classes, streams, and ranges. In this section we would only discuss rang

Sorted list using binary search technique, Write an algorithm for searching...

Write an algorithm for searching a key from a sorted list using binary search technique 1.   if (low > high) 2.     return (-1) 3.    mid = (low +high)/2; 4    .if ( X

How do collisions happen during hashing, How do collisions happen during ha...

How do collisions happen during hashing? Usually the key space is much larger than the address space, thus, many keys are mapped to the same address. Assume that two keys K1 an

Standard ways of traversing a graph, Q. Which are the two standard ways of ...

Q. Which are the two standard ways of traversing a graph?  Explain them with an example of each.  Ans:   T he two ways of traversing a graph are written below

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd