I am trying to complete an assignment, but first need to get the program to run. I get a debug error, "numberArray being used without being initialized. Am I'm missing something? I am using three functions. one to get the highest number in an array, second to get the lowest and passed by pointer notation, and third to change letters to capital.
// INCLUDES AND NAMESPACES
#include <iostream>
#include <iomanip>
using namespace std;
// DEFINES
#define ARRAY_SIZE 20
#define STRING_SIZE 20
// FUNCTION PROTOTYPES
int ReturnLargest(int);
int ReturnSmallest(int*);
int ToUpperCase(char*);
// GLOBALS
int highest;
int lowest;
int z;
// MAIN
int main() {
int numberArray[20];
char myGreeting[] = "Hello Merry Christmas";
int ReturnLargest(numberArray[20]);
int* ReturnSmallest(numberArray);
int ToUpperCase(myGreeting[20]);
cout << highest << endl;
cout << lowest << endl;
cout << z << endl;
return 0;
}
// FUNCTION IMPLEMENTATIONS
int ReturnLargest(int numberArray[20]) {
int highest;
int i;
int n;
int max = numberArray[0];
for(i = 0; i < ARRAY_SIZE; i++) {
if(numberArray[i+1] > numberArray[i]) {
highest = numberArray[i+1];
}
else {
highest = numberArray[i];
}
}
return highest;
}
int ReturnSmallest(int* numberArray) {
int lowest;
int i;
int n;
int minimum = numberArray[0];
for(i = 0; i < ARRAY_SIZE; i++) {
if(numberArray[i+1] < numberArray[i]) {
lowest = numberArray[i+1];
}
else {
lowest = numberArray[i];
}
}
return lowest;
}
int ToUpperCase(char* myGreeting) {
char tempArray[STRING_SIZE] = ""; // make an empty holder string
int i = 0; // counter used to iterate through the string
int j = 0; // counter used to iterate through the string
//int z = 0; // counter used to iterate through the temp string
// read letters from the end of reverseMe and put them
// in the temporary array until the string is empty
z = 0;
while(myGreeting[i] != '\0') {
j = 0;
// find the last character in reverseMe
while(myGreeting[j + 1] != '\0')
j++;
// copy that character into the temp array and terminate tempArray
tempArray[z++] = myGreeting[j];
tempArray[z] = '\0';
// terminate reverseMe on the last character
myGreeting[j] = '\0';
}
// tempArray now contains the reversed string
// copy the contents of tempArray back into reverseMe
i = 0;
while(tempArray[i] != '\0') {
myGreeting[i] = tempArray[i];
i++;
}
myGreeting[i] = '\0';
return z;
}