The problem is based on a program that asks to calculate the sum of the elements above the secondary diagonal, calculate the sum of the secondary diagonal and divide the first by the second (matrices), that is: sum elements above of secondary diagonal / secondary diagonal sum. the quotient must be mandatorily sent from the main and the calculation of the quotient and the rest within a function. Here is the code:
int main( void ) {
int mat2A[TAM_MAT][TAM_MAT];
float cociente;
puts("Probando parte 2-a.-");
cargarMatParteA(mat2A, TAM_MAT, TAM_MAT, !CON_CERO, NEGA1);
mostrarMatParteA(mat2A, TAM_MAT, TAM_MAT);
if(calcularcociente_mia(mat2A, TAM_MAT, TAM_MAT, &cociente))
printf("El cociente es %f.\n\n", cociente);
}
int calcularcociente_mia(int mat[][TAM_MAT], int cantFi, int cantCo, float *cociente) {
int suma=0;
int sumadiagonal=0;
for (cantFi=TAM_MAT-1;cantFi>=0;cantFi--) {
for(cantCo=0;cantCo<TAM_MAT-cantFi-1;cantCo++) {
suma+= *(mat+cantFi*TAM_MAT+cantCo);
}
}
for(cantFi=0,cantCo=TAM_MAT-1;cantFi<TAM_MAT;cantFi++,cantCo--) {
sumadiagonal+= *(mat+cantFi*TAM_MAT+cantCo);
}
*cociente = (float) suma/(float)sumadiagonal;
return cociente;
}