sparse matrix 😁

Run Settings
LanguageC
Language Version
Run Command
#include <stdio.h> int main() { int r, c, a[100][100], i, j,count=0; printf("Enter the number of rows (between 1 and 100): "); scanf("%d", &r); printf("Enter the number of columns (between 1 and 100): "); scanf("%d", &c); printf("\nEnter elements of matrix:\n"); for (i = 0; i < r; ++i) for (j = 0; j < c; ++j) { scanf("%d", &a[i][j]); } // adding two matrices for (i = 0; i < r; ++i) for (j = 0; j < c; ++j) { if (a[i][j] == 0){ count++; } } for (i = 0; i < r; ++i){ for (j = 0; j < c; ++j) { printf("%d ", a[i][j]); } printf("\n"); } if (count > (i+j)/2){ printf("given matrix is spasre matrix "); }else{ printf("No Baby NO 🤣 "); } return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines