Hi im new at stackoverflow and also beginner into c and trying to solve this problem My code is
#include <stdio.h>
int main(){
    int sales[5][4];
    int salesPersons, products=0;
    int value=0;
    printf("Enter salesperon number: ");
    scanf("%d", &salesPersons);
    
    while(salesPersons != 0){
        printf("Enter product number: ");
        scanf("%d", &products);
        printf("Enter value: ");
        scanf("%d", &value);
        if(salesPersons >= 1 && products >= 1 && products < 6 && value >= 0)
            sales[products - 1][salesPersons - 1] += value;
        else
            printf("Invalid input!\n");
        printf("Enter salesperson number (Enter 0 to exit inputting): ");
        scanf("%d", &salesPersons);
    }
    printf("%7s%7s%7s%7s%7s%7s%7s\n", "N", "P1", "P2", "P3", "P4", "P5", "TOTAL");
    int totalProduct[5] = {0}, totalPerson[4] = {0};
    for (int row = 0; row < 5; row++) {
        printf("%7d", row + 1);
            for (int column = 0; column < 5; column++) {
                printf("%7d", sales[row][column]);
                totalProduct[row] += sales[row][column];
                totalPerson[column] += sales[row][column];
        }
        printf("%7d\n", totalProduct[row]);
    }
    printf("%7s%7d%7d%7d%7d%7d\n", "TOTAL", totalPerson[0],totalPerson[1],totalPerson[2],totalPerson[3],totalPerson[4]);
    return 0;
}
I tested with only 1 salesperson, product, and value. But turns out the output printing number it shouldnt printed. Anyone know how to fix this?
Enter salesperon number: 1
Enter product number: 2
Enter value: 3
Enter salesperson number (Enter 0 to exit inputting): 0
      N     P1     P2     P3     P4     P5  TOTAL 
      11928634432  2208215775231      0    1971944432139
      2    197      0-1490587977  32766-14905879781313824304
      3-1490587978  327661928639853  22082-34104450497062219
      4-341044504  327421928639776  22082      01587650096
      5      0      01928638656  22082-1490587712438073026
  TOTAL97002147  8759016138243  99012-1377788055
 
    