Created
October 16, 2019 18:38
-
-
Save parzibyte/38063bed9f15167504bf19dd4d27cee5 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
package main | |
import "fmt" | |
func main() { | |
var calificacionIntroducida int // Para escanear cada calificacion introducida por el usuario | |
var calificaciones[10] int //Aquí guardaremos los valores | |
/* | |
Preguntar cada valor... | |
*/ | |
for i:= 0; i < 10; i++{ | |
fmt.Printf("\nIntroduce la calificación %d: ", i + 1) | |
fmt.Scanf("%d\n", &calificacionIntroducida) | |
calificaciones[i] = calificacionIntroducida // y asignarlo | |
} | |
/* | |
Calcular promedio | |
*/ | |
sumatoria := 0 | |
for _,calificacion := range calificaciones{ | |
sumatoria += calificacion | |
} | |
promedio := sumatoria / len(calificaciones) | |
fmt.Printf("El promedio es %d", promedio) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment