Created with <3 with dartpad.dev.
Created
October 24, 2023 02:56
-
-
Save leonus96/a75ad34cac8990d7b73b6be93daf9e8a to your computer and use it in GitHub Desktop.
promedio
This file contains hidden or 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
| /// 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