A practical data program can reduce small table columns into a deterministic total.

row count The selected row count controls how much of the fixed table participates in the summary.
total Each row contributes `quantity * price` to the final total.

CSV Totals

rowCount
csv_totals.c
Replay: real traced execution (multi-file project)
#include <stdio.h>

int main(void) {
    int rowCount = 3;
    int quantities[3] = {2, 4, 6};
    int prices[3] = {5, 3, 2};
    int total = 0;

    for (int i = 0; i < rowCount; i++) {
        total += quantities[i] * prices[i];
    }

    printf("rows=%d total=%d\n", rowCount, total);
    return 0;
}
#include <stdio.h>

int main(void) {
    int rowCount = 1;
    int quantities[3] = {2, 4, 6};
    int prices[3] = {5, 3, 2};
    int total = 0;

    for (int i = 0; i < rowCount; i++) {
        total += quantities[i] * prices[i];
    }

    printf("rows=%d total=%d\n", rowCount, total);
    return 0;
}
#include <stdio.h>

int main(void) {
    int rowCount = 2;
    int quantities[3] = {2, 4, 6};
    int prices[3] = {5, 3, 2};
    int total = 0;

    for (int i = 0; i < rowCount; i++) {
        total += quantities[i] * prices[i];
    }

    printf("rows=%d total=%d\n", rowCount, total);
    return 0;
}
  1. rowCount ← 3, quantities ← ⟨addr A⟩, prices ← ⟨addr B⟩, total ← 0

    3int main(void) {4    int rowCount→ 3 = 3; //@rowCount=1, 25    int quantities→ ⟨addr A⟩[3] = {2, 4, 6};6    int prices→ ⟨addr B⟩[3] = {5, 3, 2};7    int total→ 0 = 0;
  2. total ← 10

    pass 1 of 3
    9for (int i0 = 0; i < rowCount3; i++) {10    total→ 10 += quantities[i]2 * prices[i]5;11}
    All 3 passes — pass 1 is the card above
    passiquantities[i]prices[i]total
    10250 10
    214310 22
    326222 34
  3. printf("rows=%d total=%d ", rowCount, total);

    13    printf("rows=%d total=%d\n", rowCount3, total34);14    return 0;15}
    outputrows=3 total=34
  1. rowCount ← 1, quantities ← ⟨addr A⟩, prices ← ⟨addr B⟩, total ← 0

    3int main(void) {4    int rowCount→ 1 = 1;5    int quantities→ ⟨addr A⟩[3] = {2, 4, 6};6    int prices→ ⟨addr B⟩[3] = {5, 3, 2};7    int total→ 0 = 0;
  2. total ← 10

    9for (int i0 = 0; i < rowCount1; i++) {10    total→ 10 += quantities[i]2 * prices[i]5;11}
  3. printf("rows=%d total=%d ", rowCount, total);

    13    printf("rows=%d total=%d\n", rowCount1, total10);14    return 0;15}
    outputrows=1 total=10
  1. rowCount ← 2, quantities ← ⟨addr A⟩, prices ← ⟨addr B⟩, total ← 0

    3int main(void) {4    int rowCount→ 2 = 2;5    int quantities→ ⟨addr A⟩[3] = {2, 4, 6};6    int prices→ ⟨addr B⟩[3] = {5, 3, 2};7    int total→ 0 = 0;
  2. total ← 10

    pass 1 of 2
    9for (int i0 = 0; i < rowCount2; i++) {10    total→ 10 += quantities[i]2 * prices[i]5;11}
  3. total ← 22

    pass 2 of 2
    9for (int i1 = 0; i < rowCount2; i++) {10    total→ 22 += quantities[i]4 * prices[i]3;11}
  4. printf("rows=%d total=%d ", rowCount, total);

    13    printf("rows=%d total=%d\n", rowCount2, total22);14    return 0;15}
    outputrows=2 total=22