Program 136:
//Coming Soon...
Output:
After 1st run:
After 2nd run:
#include<stdio.h>
main()
{
int i,j,rows,col,count=0;
printf("Enter number of rows and columns of a matrix\n");
scanf("%d %d",&rows,&col);
int a[rows][col];
//Taking input of matrix
printf("Enter Matrix 1\n");
for(i=0;i<rows;i++)
{
for(j=0;j<col;j++)
{
scanf("%d",&a[i][j]);
if(a[i][j]==0)
{
count++;
}
}
}
printf("Given /matrix is\n");
for(i=0;i<rows;i++)
{
for(j=0;j<col;j++)
{
printf("%d\t",a[i][j]);
}
printf("\n");
}
if(count>((rows*col)/2))
{
printf("Number of zeros is %d\n",count);
printf("Number of elements other than zero are %d\n",(rows*col)-count);
printf("As zeros are greater than remaining elements\n");
printf("Hence Given Matrix is Sparse Matrix \n");
}
else
{
printf("Number of zeros is %d\n",count);
printf("Number of elements other than zero are %d\n",(rows*col)-count);
printf("As zeros are lesser than remaining elements\n");
printf("Hence Given Matrix is not Sparse Matrix \n");
}
}
Explanation://Coming Soon...
Output:
After 1st run:


