Skip to content

Instantly share code, notes, and snippets.

@leonus96
Created October 24, 2023 02:56
Show Gist options
  • Save leonus96/a75ad34cac8990d7b73b6be93daf9e8a to your computer and use it in GitHub Desktop.
Save leonus96/a75ad34cac8990d7b73b6be93daf9e8a to your computer and use it in GitHub Desktop.
promedio
/// Crea una función llamada
/// calcularPromedio que tome una lista
/// de números como parámetro y
/// devuelva el promedio de esos números.
void main() {
final List<int> notas = [34, 32, 5, 3, 12, 6, 8];
print('El promedio de las notas es: ${calcularPromedio(notas)}');
}
double calcularPromedio(List<int> notas) {
int suma = 0;
for (int i = 0; i < notas.length; i++) {
suma = suma + notas[i];
}
return suma/notas.length;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment