Advertisement
libardorengifo

Student marks

Apr 20th, 2021
603
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.91 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3.  
  4. float promedio_notas(float notas[], int cantidad_notas){
  5.     float prom = 0;
  6.     for(int i=0; i<cantidad_notas; i++) prom += notas[i];
  7.     return prom / cantidad_notas;
  8. }
  9.  
  10. void mostrar_resultado(float notas[], float promedio, int cantidad_notas){
  11.    int aprobados=0, reprobados=0;
  12.    for(int i=0; i<cantidad_notas; i++) {
  13.         if(notas[i] >= promedio) aprobados++;
  14.     }
  15.     printf("Promedio: %.2f\n", promedio);
  16.     printf("Aprobados: %d\n", aprobados);
  17. }
  18.  
  19. int main(void)
  20. {
  21.     int cantidad_notas = 100;
  22.     float notas[cantidad_notas];
  23.     float nota, promedio;
  24.     int aprobados=0, reprobados=0, i=0;
  25.     while(i<cantidad_notas){
  26.         printf("Coloque la nota %d: ", i+1);
  27.         scanf("%f", &nota);
  28.         notas[i] = nota;
  29.         i++;
  30.     }
  31.     promedio = promedio_notas(notas, cantidad_notas);
  32.     mostrar_resultado(notas, promedio, cantidad_notas);
  33.     return 0;
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement