Created
January 7, 2020 23:32
-
-
Save parzibyte/04d80b63dd1acc7d70b36595b29f96fb to your computer and use it in GitHub Desktop.
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
class Main { | |
public static void main(String[] args) { | |
int arreglo[] = { 1, 3, 4, 90, 92 }; | |
// Para obtener la suma recorremos el arreglo y sumamos cada valor | |
int suma = 0; | |
for (int x = 0; x < arreglo.length; x++) { | |
suma = suma + arreglo[x]; | |
} | |
// El promedio es la suma dividida entre la cantidad de elementos | |
float promedio = suma / arreglo.length; | |
System.out.printf("Suma: %d. Promedio: %f", suma, promedio); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment