Program Console Vignaankosh.com
Execution Panel
Console is empty.
Check if Matrix is Sparse (More Zeros than Non-Zeros) is an interactive C dry run visualizer from the Two D programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.
This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.
#include <stdio.h>
int main() {
int matrix[4][4] = {{0, 0, 3, 0}, {0, 0, 0, 0}, {1, 0, 0, 0}, {0, 0, 0, 2}}, i, j;
int zeroCount = 0, total = 16;
for(i = 0; i < 4; i++) {
for(j = 0; j < 4; j++) {
if(matrix[i][j] == 0) {
zeroCount++;
}
}
}
if(zeroCount > total/2)
printf("Matrix is Sparse (%.1f%% zeros)\n", (float)zeroCount/total*100);
else
printf("Matrix is NOT Sparse (%.1f%% zeros)\n", (float)zeroCount/total*100);
return 0;
}