Guest User

Untitled

a guest
Apr 17th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <stdio.h>
  2. #define MAX 100
  3. int main ()
  4. {
  5. int estaturas[MAX];
  6. int i=0, alumnos,j;
  7. float media;
  8.  
  9. printf ("Introduzca el numero de alumnos que hay en la clase: ");
  10. scanf ("%d", &alumnos);
  11. printf ("La clase consta de %d alumnos",alumnos);
  12.  
  13.  
  14.  
  15. if (alumnos<2 || alumnos>MAX)
  16. {
  17. printf ("Error.\n");
  18. return -1;
  19. };
  20.  
  21.  
  22. while (i<alumnos)
  23. {
  24.  
  25. printf ("\nIntroduzca la altura del alumno numero %d en centimetros ",i+1);
  26. scanf("%d",estaturas[i]);
  27. i++;
  28. };
  29.  
  30. for (j=0;j<alumnos;j++)
  31. {
  32. media= media+estaturas[j];
  33. };
  34.  
  35. media =media/alumnos;
  36.  
  37. printf("La media de altura es %f",media);
  38.  
  39. return 0;
  40. }
Add Comment
Please, Sign In to add comment