Advertisement
gonzalob

Untitled

Apr 18th, 2022
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. //un arreglo es una colección de elementos del mismo tipo
  7. //tiene un solo nombre "notas"
  8. //tiene una dimension "100"
  9. //la primera posición es la 0 y la utima DIM-1 (0-4)
  10. //la cantidad de elementos es FIJA
  11. int notas[5] = {0} ;
  12. char wordle[5];
  13. float precios[10];
  14.  
  15.  
  16. /*
  17. for (int i = 0; i<5; i++)
  18. {
  19. notas[i] = i;
  20. }
  21. */
  22.  
  23. //notas[0] = 1; //a la posición 0 (la primera) un numero (1)
  24.  
  25. // int valor = 10;
  26.  
  27. // notas[1] = valor; //a la posición 1 (la segunda) un numero (10)
  28.  
  29.  
  30.  
  31. for (int i = 0; i<5; i++)
  32. {
  33. printf("ingrese el valor en la pos %d \n",(i+1));
  34. fflush(stdin);
  35. scanf("%d",&notas[i]);
  36. }
  37.  
  38. for (int i = 0; i<5; i++)
  39. {
  40. printf("el valor en la pos %d es %d\n",(i+1),notas[i]);
  41. }
  42.  
  43. float promedio = 0;
  44. int acumulador = 0;
  45.  
  46. for (int i = 0; i<5;i++)
  47. {
  48. acumulador = acumulador + notas[i];
  49. }
  50.  
  51. promedio = (float) (acumulador / 5);
  52.  
  53. printf("el promedio es %f\n",promedio);
  54.  
  55. return 0;
  56. }
  57.  
  58.  
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement