bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

root / semester_1 / tuition-c / APC-S-012.c

APC-S-012.c (880B)


      1 /* Write a program to check if a matrix is a sparx matrix. */
      2 /* Author: Amit Dutta, Date: 19-11-2025 */
      3 
      4 #include <stdio.h>
      5 
      6 int main()
      7 {
      8     int i, j, row, col, count = 0;
      9 
     10     printf("Enter the number of rows and columns in the matrix: ");
     11     scanf("%d %d", &row, &col);
     12 
     13     int matrix[row][col];
     14 
     15     for (i = 0; i < row; i++)
     16         for (j = 0; j < col; j++)
     17         {
     18             printf("Postion %d%d: ", i, j);
     19             scanf("%d", &matrix[i][j]);
     20             if (matrix[i][j] == 0)
     21                 count++;
     22         }
     23 
     24     printf("\nEntered Matrix: \n");
     25     for (i = 0; i < row; i++)
     26     {
     27         for (j = 0; j < col; j++)
     28             printf("%d  ", matrix[i][j]);
     29         printf("\n");
     30     }
     31 
     32     if (count > (row * col) / 2)
     33         printf("\nEntered matrix is a Sparx Matrix.");
     34     else
     35         printf("\nEntered matrix is not a Sparx Matrix");
     36     return 0;
     37 }
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror