// A Sparse Matrix is a matrix with a number of 0's greater than the number of non-zero elements
#include <stdio.h>
int main()
{
int matrix[3][3] = {{2, 0, 5},
{0, 4, 0},
{0, 8, 0}};
size_t rows = sizeof matrix/sizeof matrix[0];
size_t cols = (sizeof matrix/sizeof matrix[0][0])/rows;
int counter = 0;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
if (matrix[i][j] == 0) {
counter++;
}
}
}
if (counter > ((rows * cols) / 2)) {
printf("Sparse matrix");
}
else {
printf("NOT sparse matrix");
}
return 0;
}
/*
run:
Sparse matrix
*/