So, I defined my functions globally so they are recognized, but I'm not allowed to define my variables globally, and now my variables are not recognized within my function definitions. ( Error: "identifier -variableName- is undefined".) Any suggestions to solve this would be much appreciated!
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <time.h>
#define PAUSE system("pause")
#define SIZE 10
int main(void) {
void enterNumbers();
void addNumbers();
void numbersAveraged();
void displayNumbers();
int i = 0;
int usersArray[SIZE] = { 0 };
int numbers = 0;
int totalOfInput = 0;
int averageOfInput = 0;
int count = 0;
int option = 0;
do {
printf("==========================================================\n");
printf("=================Number Management System====================\n");
printf("============================================================\n\n");
printf("Things you can do here.\n");
printf("\n1. Give us numbers to work with! \n");
printf("\n2. Let Me add all the numbers you gave me.\n");
printf("\n3. I will display the average of all of the numbers you've put in.\n");
printf("\n4. I will display all of the numbers you put in. \n");
printf("\n5. Exit \n");
scanf("%i", &option);
switch (option) {
case 1:
enterNumbers();
break;
case 2:
addNumbers();
break;
case 3:
numbersAveraged();
break;
case 4:
displayNumbers();
break;
case 5:
exit(0);
break;
default:
printf("This is not a valid choice, please type 1-5. ");
PAUSE;
}
} while (option != 5);
void enterNumbers(); {
for (i = 0; i == SIZE; i++) {
printf("Please type in a number. Enter -1 when you are done entering numbers.");
scanf("%i", &usersArray[i]);
count++;
if (usersArray[i] == -1) {
break;
}
if (i == SIZE) {
printf("That's enough numbers! I can't hold any more I'm afraid.");
}
}
}
void addNumbers(); {
void enterNumbers();
for (i = 0; i < count; i++) {
totalOfInput += usersArray[i];
}
printf("OK, so the total of all of these numbers is: %d", totalOfInput);
}
void numbersAveraged(); {
addNumbers();
averageOfInput = totalOfInput / i;
printf(" The average of the numbers you added was %i", averageOfInput);
}
void displayNumbers(); {
printf("OK, here are all of the numbers you put in. \n");
for (i = 0; i < count; i++) {
printf("%d \n", usersArray[i]);
}
}
}