Advertisement
Guest User

ocb

a guest
Nov 23rd, 2014
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main()
  4. {
  5.  
  6.     int N, i, suma=0;
  7.     int tab[N];
  8.     printf("Podaj wielkosc tablicy: \n");
  9.     scanf("%d", &N);
  10.  
  11.     srand((unsigned) time (NULL));
  12.     for(i=0; i<N; i++)
  13.     {
  14.         tab[i] = rand() % 10;
  15.         printf("%d\t", tab[i]);
  16.     }
  17.  
  18.     for(i=0; i<N; i++)
  19.     {
  20.         suma+=tab[i];
  21.     }
  22.     printf("Suma wszystkich elementow wynosi: %d\n\n", suma);
  23.  
  24.     printf("Suma arytmetyczna %d- elementowej tablicy wynosi: %f\n\n", N, (float)suma/N);
  25.  
  26.  
  27.  
  28.  
  29.  
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement