APC-S-012.c ​
Metadata ​
- Author — Amit Dutta (amitdutta4255@gmail.com)
- Last updated — 12 Dec 2025
- License — MIT
Problem Statement ​
Problem Statement
Write a program to check if a matrix is a sparx matrix.
Source Code ​
Printing the code
To print this file, open it on GitHub and click Raw before printing, or use the Download Raw button above and print directly from that page.
c
#include <stdio.h>
int main()
{
int i, j, row, col, count = 0;
printf("Enter the number of rows and columns in the matrix: ");
scanf("%d %d", &row, &col);
int matrix[row][col];
for (i = 0; i < row; i++)
for (j = 0; j < col; j++)
{
printf("Postion %d%d: ", i, j);
scanf("%d", &matrix[i][j]);
if (matrix[i][j] == 0)
count++;
}
printf("\nEntered Matrix: \n");
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
printf("%d ", matrix[i][j]);
printf("\n");
}
if (count > (row * col) / 2)
printf("\nEntered matrix is a Sparx Matrix.");
else
printf("\nEntered matrix is not a Sparx Matrix");
return 0;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34