// Pantea Aria // 1D array and functions recap // read size of the array from user // write functions to // read size integer to an array of int // print out all data of the arrays // find the maximum and return to main #include void input(int size, int numbers[]); int maximum(int size, int numbers[]); void output(int size, int numbers[]); int main(void) { // declare the array of size int size; printf ("Enter size of the array:"); scanf ("%d", &size); printf ("The value of size is: %d", size); int numbers[size]; // call function input to read size integer to an array of int input(size, numbers); // call output to print out all data of the arrays output(size, numbers); // find the maximum and return to main // call a non void function inside printf printf("The maximum of all is %d\n", maximum(size, numbers)); return 0; } void input(int size, int numbers[]){ int i = 0; printf ("Enter %d integers:", size); while(i < size) { scanf("%d", &numbers[i]); i++; } return; } void output(int size, int numbers[]){ int i = 0; printf ("All elements are:"); while(i < size) { printf("%d ", numbers[i]); i++; } printf ("\n"); return; } int maximum(int size, int numbers[]) { int max = numbers[0]; // then go the whole array // and compare all other elements with max int i = 0; while (i < size) { if (max < numbers[i]) { max = numbers[i]; } i++; } return max; }