why do we write only the signature of a function addNumbers at the start of the code and later we write the whole function??
how do we define that scanf command will be separated by spaces??
Code:
#include <stdio.h>
int addNumbers(int *fiveNumbers);
int main() {
int array[5];
int i;
printf("Enter 5 integers separated by spaces: ");
for(i=0 ; i<5 ; i++) {
scanf("%d", &array[i]);
}
printf("\nTheir sum is: %d\n", addNumbers(array));
return 0;
}
int addNumbers(int *fiveNumbers) { /* define function */
int sum = 0;
int i;
for(i=0 ; i<5 ; i++, fiveNumbers++) {
sum+= *fiveNumbers); /* work out the total */
}
return sum; /* return the total */
}