Wednesday, 14 March 2018

LNK2019 - Unresolved External Symbol C++

I am new to C++ and have no idea where to look exactly. My program seems to be getting an error labeled as LNK2019 - Unresolved External Symbol.



Exact Message is:
"error LNK2019: unresolved external symbol "double_cdecl computeSTD(double*const, int)" (?computeSTD@@YANQANH@Z) referenced in function_main)"



If you can provide any advice on how I might learn to fix these types of errors I would be most grateful!



Provided below is a copy of my source code.



#include 

#include // for Setprecision
#include // for pow and sqrt

using namespace std;

//Prototypes
void programInformation();
void inputArrayValues (double array[], int SIZE, int &count);
void printListOriginal (double array[], int count);
void sortAscending (double array[], int count);

double computeAverage (double array[], int count);
double computeMedian (double array[], int count);
double computeSTD (double array[], int count);
void printCalculations (double average, double median, double std);

int main()
{
// Declare Local Variables
const int SIZE=30.0;
double array[SIZE];

double average;
double median;
double std;
int count = 0;

// Set Precision for Decimal Points
cout << setprecision(1) << fixed <
// Module Call for Program Infomation
programInformation();


// Module/Function Calls
inputArrayValues (array, SIZE, count);
printListOriginal (array, count);
sortAscending (array, count);
average = computeAverage (array, count);
median = computeMedian (array, count);
std = computeSTD (array, count);
printCalculations (average, median, std);
return 0;

}

//Module: programInformation
//Description: Provide the user with the author, title of the program, and its function.
void programInformation()
{
cout << "*********************************************" << endl;
cout << "*** Author: - ***" << endl;
cout << "*** Statistical Calculator ***" << endl;
cout << "*********************************************" << endl;

}

//Module: inputArrayValues
//Description: Ask the user to input values between 3 and 30 elements for the array to hold. Also validates that the user inputs a total of values between 3 and 30.
void inputArrayValues (double array[], int SIZE, int &count)
{
double number = 0;
// Basic information about what the user can input. Does not repeat.
cout << "Please enter values one at a time." < cout << "Up to a maximum of 30 values and a minimum of 3 values." << endl;

cout << "Only positive values are accepted or the program will not work." << endl;
cout << "With the exception, please enter the value -1.0 to stop entering values." << endl;

// Do-While Loop
// Variable count is counting how many values the user inputs for later calculation
while (number != 1.0)
{
for (int i = 0; i < SIZE; i++)
{
cout << "Please enter a value or enter -1.0 to stop entering values" << endl;

cin >> number;
array[i] = number;
if (number != 1.0)
{
count++;
}

}
}


if (count < 3 || count > SIZE)
{
cout << "Invalid total number of values." << endl;
cout << "The total number of values must between 3 and 30 values." < cout << "This program will now close..." << endl;
cout << "Thank you for using this program." << endl;
}
}
//Module: printListOriginal
//Description: Prints out the values that the user entered 5 values per line

void printListOriginal (double array[], int count)
{
int i = 0;
while (i < count)
{
cout < i++;
if (i > 5)
{
cout << endl;

i= 0;
}
}
}
//Module: sortAscending
//Description: Sorts the given inputs in Ascending Order and Displays the sorted list.
void sortAscending (double array[], int count)
{
int i;
int j = 0;

double temp;
for (i = 0; i < count; i++)
{
if (array[j+1] < array[j])
{
temp = array[j];
array[j] = array[j+1];
array [j+1] = temp;
}
}

int k = 0;
while (k < count)
{
cout < k++;
if (k > 5)
{
cout << endl;
k= 0;
}

}
}
//Function: comupteAverage
//Description: Computes the average of the given inputs.
double computeAverage (double array[], int count)
{
double sum = 0.0;
double resultA;
for (int i =0; i < count; i++)
{

sum = sum + array[i];
}
resultA = sum / count;
return resultA;
}
//Function: computeMedian
//Description: Computes the Median of the given inputs.
double computeMedian (double array[], int count)
{
double resultM;

if ((count % 2) == 0)
{
resultM = (array[count/2] + (array[count/2] -1.0) /2.0);
}
else
resultM = array[count/2];
return resultM;
}
//Function: computeSTD
//Description: Computes the Standard Deviation of the given inputs.

double computeSTD (double array[], int count, double average)
{
double temp;
double sum = 0;
double resultV;
for(int i = 0; i < count; i++)
{
temp = pow((array[i] - average), 2);
sum = sum + temp;
}

//Account for Sample Standard Deviation N-1
resultV = sqrt(sum/(count -1));
return resultV;
}
//Module: printCalculations
//Description: Prints the Average, Median, and Standard Deviation
void printCalculations (double average, double median, double std)
{
cout << "The average is: " << average << endl;
cout << "The median is: " << median << endl;

cout << "The Standard Deviation is: " << std << endl;
}

No comments:

Post a Comment

casting - Why wasn&#39;t Tobey Maguire in The Amazing Spider-Man? - Movies &amp; TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...