Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. int main()
  5. {
  6. int tab[20];
  7. int i, suma;
  8. float srednia; /* generowanie pseudolosowe elementów macierzy */
  9. srand(time(NULL));
  10. for(i=0; i<20; i++)
  11. tab[20] = rand() % 10;
  12.  
  13. for(i=0; i<20; i++)
  14. {
  15.  
  16. printf("%3d",tab[20]);
  17. printf( "\n" );
  18. }
  19. printf( "\n");
  20. suma = 0;
  21. for(i=0; i<20; i++)
  22. suma = suma + tab[20];
  23. srednia = (float) suma/(20);
  24. printf("Suma elementow: %d\n",suma);
  25. printf("Srednia arytmetyczna: %f\n \n",srednia);
  26. {
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement