#include "Test.h"

unsigned char sum(unsigned char table[],unsigned char size); // prototip funkcije

#define SIZE 8 
unsigned char tab8[SIZE]= {15,120,112, 34, 55, 23, 3, 6};  //deklaracija polja 8-bitnih vrednosti

int main()
{ 
   int temp;
   temp = sum (tab8, SIZE);    // sporoci polje in velikost
   
   printf("Koncno povprecje tab8 = %d\n",temp);
}  

unsigned char sum(unsigned char table[],unsigned char size){
   int i, vsota=0;
   unsigned char average;
   
   for(i=0; i<size; ++i) {   // izracunaj vsoto elementov polja
      vsota += table[i];
   }
   average = vsota / size ;  // izracunaj povprecno vrednost
   printf("Vsota = %d; Ave = %d\n",vsota,average);
   return average;
}