0

I do not like posting here unless it is a last resort. I enjoy trying to figure it out on my own. but I have been stuck on this for far too long and all of my google searches have ended up being useless. here is my code and the errors i get when debugging.

#include <iostream>
#include <fstream>
using namespace std;

//function prototypes
int getLowest(int[]);
int getHighest(int []);
int getSum(int []);
double getAverage(int);

//global variables
int Lowest, Highest, Sum;
double Average;

//arrays
const int ArraySize = 12;
int numbers[12];

//function main. read numbers from file into array.
//display lowest, highest, sum and average.
int main()
{

int count;
ifstream inputFile;
inputFile.open("numbers.txt");

for (count = 0; count < ArraySize; count++)
    inputFile >> numbers[count];

Lowest = getLowest(numbers);
Highest = getHighest(numbers);
Sum = getSum(numbers);
Average = getAverage(Sum);

inputFile.close();

cout << "the lowest number is " << Lowest << endl;
cout << "the highest number is " << Highest << endl;
cout << "the sum of the numbers is " << Sum << endl;
cout << "the average of the numbers is " << Average << endl;

system("pause");
return 0;

}

int getLowest()

{
int Low = numbers[1];
for (int count = 0; count < 11; count++)
    if (numbers[count] < Low)
    {
        Low = numbers[count];
    }

return Low;
}

int getHighest()

{
int High = numbers[1];
for (int count = 0; count <11; count++)
    if (numbers[count] < High)
    {
        High = numbers[count];
    }
return High;
}

int getSum()
{
int Sum = 0;

for (int count =0; count <11; count++)
    Sum = (Sum + numbers[count]);

return Sum;
}

double getAverage()
{
double Average;
Average = (Sum / 12);

return Average;
}

error when debugging

1>------ Build started: Project: Lab06-01NumberAnalysis, Configuration: Debug Win32 ------

1>NumbersAnalysis.obj : error LNK2019: unresolved external symbol "double __cdecl getAverage(int)" (?getAverage@@YANH@Z) referenced in function _main

1>NumbersAnalysis.obj : error LNK2019: unresolved external symbol "int __cdecl getSum(int * const)" (?getSum@@YAHQAH@Z) referenced in function _main

1>NumbersAnalysis.obj : error LNK2019: unresolved external symbol "int __cdecl getHighest(int * const)" (?getHighest@@YAHQAH@Z) referenced in function _main

1>NumbersAnalysis.obj : error LNK2019: unresolved external symbol "int __cdecl getLowest(int * const)" (?getLowest@@YAHQAH@Z) referenced in function _main

1>K:\School\CPET 107C Introduction to programmingwith C++\Labs\Lab06-Ch7\Lab06-01NumberAnalysis\Debug\Lab06-01NumberAnalysis.exe : fatal error LNK1120: 4 unresolved externals

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

numbers.txt is saved in folder in the same location as the .cpp any help would be appreciated at this point.

thanks in advance

Myles
  • 11
  • 3

0 Answers0