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

which type of aspect you want from the student.

1794


What are the complete rules for header file searching?

758


Write a program to maintain student’s record. Record should not be available to any unauthorized user. There are three (3) categories of users. Each user has its own type. It depends upon user’s type that which kind of operations user can perform. Their types and options are mentioned below: 1. Admin (Search Record [by Reg. No or Name], View All Records, Insert New Record, Modify Existing Record) 2. Super Admin (Search Record [by Reg. No or Name], View All Records, Insert New Record, Modify Existing Record, Delete Single Record) 3. Guest (Search Record [by Reg. No or Name], View All Records) When first time program runs, it asks to create accounts. Each user type has only 1 account (which means that there can be maximum 3 accounts). In account creation, following options are required: Login Name: <6-10 alphabets long, should be unique> Password: <6-10 alphabets long, should not display characters when user type> Confirm Password: Account Type: Login Name, Password and Account Type should be stored in a separate file in encrypted form. (Encryption means that actual information should be changed and Decryption means that Encrypted information is changed back to the actual information) If any of the above mentioned requirement(s) does not meet then point out mistake and ask user to specify information again. When Program is launched with already created accounts, it will ask for user name and password to authenticate. On successful authentication, give options according to the user’s type.

1606


Is void a keyword in c?

671


What is storage class?

750






Why can arithmetic operations not be performed on void pointers?

706


What is bss in c?

695


What is main function in c?

651


A collection of data with a given structure for excepting storing and providing on demand data for multiple users a) linked list b) datastructer c) database d) preprocessor

717


Write a factorial program using C.

733


What is size of union in c?

668


how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12

746


What is the scope of an external variable in c?

651


With the help of using classes, write a program to add two numbers.

725


Why ca not I do something like this?

681