So, this my last assignment, and i am writing a file (numbers.text) into an array and then processing the sum, highest num, lowest num. i really need a hint as to how to read the error messages.
Here is the error I receive,i assume i am passing the incorrect array size in main, but i can not figure out how to remedy this.
Error 4 error LNK2019: unresolved external symbol "int __cdecl getLowest(int * const,int)" (?getLowest@@YAHQAHH@Z) referenced in function _main E:\C++\Work\Lab6\Lab6_01\Lab_6_01_T\Lab_6_01_T\Lab6_01.obj Lab_6_01_T
Error 5 error LNK2019: unresolved external symbol "int __cdecl getHighest(int * const,int)" (?getHighest@@YAHQAHH@Z) referenced in function _main E:\C++\Work\Lab6\Lab6_01\Lab_6_01_T\Lab_6_01_T\Lab6_01.obj Lab_6_01_T
Error 6 error LNK2019: unresolved external symbol "int __cdecl getSum(int * const,int)" (?getSum@@YAHQAHH@Z) referenced in function _main E:\C++\Work\Lab6\Lab6_01\Lab_6_01_T\Lab_6_01_T\Lab6_01.obj Lab_6_01_T
Error 7 error LNK1120: 3 unresolved externals E:\C++\Work\Lab6\Lab6_01\Lab_6_01_T\Debug\Lab_6_01_T.exe 1 1 Lab_6_01_T
//prototypes
int getLowest(int[], int); // required
int getHighest(int[], int); // required
int getSum(int[], int); // required
int main()
{
const int ARRAY_SIZE = 100;
int numbers[ARRAY_SIZE];
ifstream inputFile; //File stream object
int count = 0; //Loop counter for math
double total = 0, lowestNmbr, highestNmbr, average; //Accumulator initialized with zero
// Set up numeric output formatting.
cout << fixed << showpoint << setprecision(2);
cout << "This program opens the associated file reads the numbers\n";
cout << "and outputs the lowest num., highest num., sum, and average of the numbers.\n";
cout << endl;
inputFile.open("E:\\C++\\Work\\Lab6\\Lab6_01\\numbers.txt"); // Open the file.
if (!inputFile)
cout << "Error Locating File!\n"; //Validation
else
{
for (count = 0; count < ARRAY_SIZE; count++) //save numbers into array
inputFile >> numbers[count];
}
inputFile.close(); //Close File
total = getSum(numbers, ARRAY_SIZE); //call
average = total / count;
lowestNmbr = getLowest(numbers, ARRAY_SIZE); //call
highestNmbr = getHighest(numbers, ARRAY_SIZE); //call
cout << "The sum of the numbers is " << total << endl;
cout << "The average of the numbers is " << average << endl;
cout << "The lowest number is " << lowestNmbr << endl;
cout << "The highest number is " << highestNmbr << endl;
system("pause");
}
//***********************************FIND TOTAL
int getSum(double array[], int size)
{
double total = 0; //accumulator
for (int count = 0; count < size; count++)
total += array[count];
return total;
}
//**********************************FIND LOWEST NUMBER
int getLowest(double array[], int size)
{
double lowest;
lowest = array[0];
for (int count = 1; count < size; count++)
{
if (array[count] < lowest)
lowest = array[count];
}
return lowest;
}
//*********************************FIND HIGHEST NUMBER
int getHighest(double array[], int size)
{
double highest;
highest = array[0];
for (int count = 1; count < size; count++)
{
if (array[count] > highest)
highest = array[count];
You have a mismatch between what you declare the function to be and what you define the function to be. For example, you say that getLowest() is declared as this: