I re-wrote you code logic using a do/while loop and changed the two function prototypes to what is normally done. You way was doing Indirect recursion which is when function "A" calls function "B" with function "B" calling function "A". Indirect recursion is not really a good thing for a beginner to do. Some people consider it a bad thing for experts to do.
Note: If this violates the HW rules; I do NOT care.
I got little support on my CB rules post(Linux users getting dumber). So, it looks to me that following the forum rules does not matter on this site.
Tim S.
Code:
#include <stdio.h>
#include <stdlib.h>
int menu();
void menuProcessor();
int main () {
int numbers[20] = {33, 77, 99, 2, 4, 1, 7, 12, 65, 3, 78, 5, 8, 10, 28, 27, 67};
menuProcessor ();
//getch();
return 0;
}
int menu () {
int menuItem;
// system("cls");
printf("Please select from the following options:\n");
printf("1. Print the content of the array\n");
printf("2. Compute the average of the array\n");
printf("3. Compute the sum of the array\n");
printf("4. Print the content of the array in reverse order\n");
printf("5. Add a value to each element of the array\n");
printf("6. Exit\n");
scanf("%d", &menuItem);
return menuItem;
}
void menuProcessor () {
int menuItem = 0;
do {
menuItem = menu();
printf("menuItem: %d\n", menuItem);
} while ((menuItem < 1) || (menuItem > 6));
return;
}