how to generate sparse matrix in c

Answer Posted / it career point

//program to 3-tuple representation
#include<stdio.>
#include<conio.h>
void main()
{
int a[5][5],row,columns,i,j;
printf(Ënter the order of the matrix.(5*5)");
scanf("%d%d",&row,&columns);
printf("Enter the element of the matrix\n");
for(i=0;i<row;i++)
for(j=0;j<columns;j++)
{
scanf("%d", &a[i][j]);
}
printf("3-tuple representation");
for(i=0;i<row;i++)
for(j=0;j<column;j++)
{
if(a[i][j]!=0)
{
printf("%d %d %d", (i+1),(j+1),a[i][j]);
}
}

getch();
}

Is This Answer Correct ?    41 Yes 42 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions?

981


What would happen to X in this expression: X += 15; (assuming the value of X is 5)

1306


The __________ attribute is used to announce variables based on definitions of columns in a table?

673


What is exit() function?

562


What does typeof return in c?

640






What is the difference between pure virtual function and virtual function?

653


Explain what are the advantages and disadvantages of a heap?

598


what are the facialities provided by you after the selection of the student.

1661


Is multithreading possible in c?

568


What is the difference between array_name and &array_name?

780


What is sizeof int in c?

605


Where register variables are stored in c?

553


What is #include stdio h?

688


What is the argument of a function in c?

576


1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. 2) the Event Manager has to send participants to the stage to perform in the order in which they registered. Write a program that will help the Event Manager know who to call to the stage to perform. The Logic should be in Data Structures

2745