#include int main(void) { int dm[10][10]; int matrix[10][10]; int sum[10][10]; int i,j; FILE *read_file; FILE *read_file2; FILE *write_file; if((read_file=fopen("mata.txt","r"))==NULL){ printf("Failed to open file (mata.txt)."); return 0; } else { for(i=0;i<10;i++){ for(j=0;j<10;j++){ fscanf(read_file,"%d",&dm[i][j]); } } } fclose(read_file); if((read_file2=fopen("matb.txt","r"))==NULL){ printf("Failed to open file (matb.txt)."); return 0; } else { for(i=0;i<10;i++){ for(j=0;j<10;j++){ fscanf(read_file2,"%d",&matrix[i][j]); } } } fclose(read_file2); for(i=0;i<10;i++){ for(j=0;j<10;j++){ sum[i][j]=0; sum[i][j]=dm[i][j]+matrix[i][j]; } } if((write_file = fopen("sum.usr", "w")) == NULL) { printf("Failed to open file (sum.usr)."); } else { for(i = 0; i < 10; i++) { for(j = 0; j < 10; j++) { if(j == 9) { fprintf(write_file, "%d\n", sum[i][j]); } else { fprintf(write_file, "%d ", sum[i][j]); } } } } fclose(write_file); printf("The sum of the matrices has been calculated into the file sum.usr.\n"); return 0; }