Program Console Vignaankosh.com
Execution Panel
Console is empty.
Row-wise and column-wise sum is an interactive C dry run visualizer from the Pointersarrays 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 i, j;
int matrix[4][3] = {
{1, 2, 3},
{4, 5, 6},
{7, 8, 9},
{10, 11, 12}
};
int rows = 4, cols = 3;
printf("Matrix:\n");
for(i = 0; i < rows; i++) {
for(j = 0; j < cols; j++) {
printf("%3d ", matrix[i][j]);
}
printf("\n");
}
// Row-wise sum
printf("\nRow-wise sums:\n");
for(i = 0; i < rows; i++) {
int rowSum = 0;
for(j = 0; j < cols; j++) {
rowSum += *(*(matrix + i) + j);
}
printf("Row %d: %d\n", i, rowSum);
}
// Column-wise sum
printf("\nColumn-wise sums:\n");
for(j = 0; j < cols; j++) {
int colSum = 0;
for(i = 0; i < rows; i++) {
colSum += *(*(matrix + i) + j);
}
printf("Column %d: %d\n", j, colSum);
}
// Using single pointer approach
printf("\nUsing single pointer:\n");
int *ptr = &matrix[0][0];
for(i = 0; i < rows; i++) {
int rowSum = 0;
for(j = 0; j < cols; j++) {
rowSum += ptr[i * cols + j];
}
printf("Row %d: %d\n", i, rowSum);
}
return 0;
}