Last active
September 6, 2019 18:15
-
-
Save Roberto24p/f543d65acf4af56e81f5f638f6077055 to your computer and use it in GitHub Desktop.
Código para sacar promedio de cada una de las filas de un arreglo 5x5 y el promedio de total
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void ingresar(float [][5], int , float [], int ); | |
float promediosfilas(float [], int); | |
void presentar( float); | |
int main() | |
{ | |
float arreglo[5][5]={{'\0'}}, prom, promedio[5]={'\0'}; | |
ingresar(arreglo,5, promedio,5); | |
printf("*****Resultados*****\n"); | |
prom=promediosfilas(promedio,5); | |
presentar(prom/5); | |
} | |
void ingresar(float arreglo[][5], int x, float promedio[], int y) | |
{ | |
int i, j, acum; | |
for(i=0;i<x;i++) | |
{ | |
for(j=0;j<x;j++) | |
{ | |
printf("Fila %d Columna %d: ", i, j); | |
scanf("%f", &arreglo[i][j]); | |
promedio[i]=arreglo[i][j]+promedio[i];//Guarda en un vector aparte los valores de cada uno de los posiciones | |
} | |
system("cls"); | |
promedio[i]=promedio[i]/5; //Divide para 5 para sacar el promedio por filas | |
} | |
} | |
float promediosfilas(float promedio[], int x) | |
{ | |
int j; | |
float prom=0; | |
for(j=0;j<x;j++) | |
{ | |
printf("Fila %d: Promedio->%.2f\n",j,promedio[j]); //Presentas las promedios individuales de cada una de las filas | |
prom=promedio[j]+prom; //Acumula en una variable los valores | |
} | |
return prom; | |
} | |
void presentar(float prom) | |
{ | |
printf("Promedio total--> %.2f",prom); //Presentas el promedio del curso dividido para la cantidad totald de estudiantes | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment