I'm a beginner in C, and I'm trying to create a program that calculate an array's maximum, using input from keyboard. I don't understand why this code prints 4203785
. I think the algorithm is right. Can someone help me?
int calcola_massimo(int vettore[], int size) {
int max = vettore[0];
int i;
for(i = 0; i < size; i++ ){
if(vettore[i] > max){
max = vettore[i];
}
}
return max;
}
int main(int argc, char *argv[]) {
int array[10];
int j;
int max;
for(j = 0; j< SIZE; j++){
printf("Inserire valore n. %d \n", j+1);
scanf("%d", array);
}
max = calcola_massimo(array, SIZE);
printf("Il valore massimo e' : %d", max);
return 0;
}