C Programming Code Examples C > Arrays and Matrices Code Examples C Program to Determine if a given Matrix is a Sparse Matrix C Program to Determine if a given Matrix is a Sparse Matrix This C Program determines the given matrix is a sparse matrix. Sparse matrix is a matrix with the majority of its elements equal to zero. This program accepts matrix and checks whether the given matrix is a sparse matrix. #include <stdio.h> void main () { static int array[10][10]; int x, j, m, n; int counter = 0; printf("Enter the order of the matix \n"); scanf("%d %d", &m, &n); printf("Enter the co-efficients of the matix \n"); for (x = 0; x < m; ++x) { for (j = 0; j < n; ++j) { scanf("%d", &array[x][j]); if (array[x][j] == 0) { ++counter; } } } if (counter > ((m * n) / 2)) { printf("The given matrix is sparse matrix \n"); } else printf("The given matrix is not a sparse matrix \n"); printf("There are %d number of zeros", counter); }