#include <stdio.h>
#include<conio.h>
#define R 10
#define C 10
void main ()
{
int array[R][C];
int i, j, m, n;
int count = 0;
clrscr();
printf("Enter the order of the matrix \n");
scanf("%d%d", &m,&n);
printf("Enter the coefficients of the matrix \n");
for (i = 0; i < m; i++){
for (j = 0; j < n; j++){
scanf("%d", &array[i][j]);
if (array[i][j] == 0){
count++;
}}}
if (count>((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", count);
getch();
}
No comments:
Post a Comment