This program is to enter the scores, get the grades, and display the result.
However, I get a fatal error LNK1120: 1 unresolved externals
Does anyone know how to solve this problem?

``````#include <iostream>
#include <iomanip>
using namespace std;

// Function prototype
double calc_average(double sum, double num);
double score[10];

double resultNum = 0;
int i = 1; // for visual appeal
int total_times =1;
double avg = 0;
double sum = 0;
double high = 0;
double low = 100;

double jjj;

int main()
{
do
{
cout << "Enter result " << i << " (or -1 if no more results) ";
cin >> score[i];
jjj = score[i];
if(score[i]!=-1)
{
sum=sum+jjj; //save inputs before continuing
if (jjj>high)
high = jjj; //check for high grades

if (jjj<low)
low = jjj; //check for low grades

resultNum++; //used to divide average

i++;
total_times = i;
}
}while (score[i] !=-1);

////////////////////////////////////////////////////////
cout << "\nThe list of the results and grades are: " << endl;

for ( i= 1; i < total_times; i++)

cout << "Result " << i << ": " << score[i] << "\t  Grade: " << grade[i] << endl;

//////////////////////////////////////////////////////////

//calc_average function for beautiful clean code
cout << "\nThe Average of the results = " << calc_average(sum,resultNum) << endl;
cout << "The Lowest of the results = " << low << endl;
cout << "The Highest of the results = " << high << endl;
}

double calc_average(double sum, double num)
{
return (sum/num);
}

void letter(double score, double resultNum, int i)
{
if (score<60)
{
cout << "Result " << resultNum << " is a U\n" << endl;
}
if (score>=60 && score<70)
{
cout << "Result " << resultNum << " is a C\n" << endl;
}
if (score>=70 && score<90)
{
cout << "Result " << resultNum << " is a B\n" << endl;
}
if (score>=90)
{
cout << "Result " << resultNum << " is a A\n" << endl;
}
}``````

that error means the linker cannot find some or all of the libraries it needs to do its job, you'll need to check your compiler/linker documentation and installation to figure out how to make those known.

1>test.obj : error LNK2019: unresolved external symbol "void __cdecl letter(double,double,char)" (?letter@@YAXNND@Z) referenced in function _main
1>c:\users\administrator\documents\visual studio 2010\Projects\test\Debug\test.exe : fatal error LNK1120: 1 unresolved externals

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

``````#include <iostream>
#include <iomanip>
using namespace std;

// Function prototype
double score[10];

double resultNum = 0;
int i = 1; // for visual appeal
int total_times =1;
double avg = 0;
double sum = 0;
double high = 0;
double low = 100;

double jjj;
double calc_average(double sum, double num)
{
return (sum/num);
}

void letter(double score, double resultNum, int i)
{
if (score<60)
{
cout << "Result " << resultNum << " is a U\n" << endl;
}
if (score>=60 && score<70)
{
cout << "Result " << resultNum << " is a C\n" << endl;
}
if (score>=70 && score<90)
{
cout << "Result " << resultNum << " is a B\n" << endl;
}
if (score>=90)
{
cout << "Result " << resultNum << " is a A\n" << endl;
}

}

int main()
{
do
{
cout << "Enter result " << i << " (or -1 if no more results) ";
cin >> score[i];
jjj = score[i];
if(score[i]!=-1)
{
sum=sum+jjj; //save inputs before continuing
if (jjj>high)
high = jjj; //check for high grades

if (jjj<low)
low = jjj; //check for low grades

resultNum++; //used to divide average

i++;
total_times = i;
}
}while (score[i] !=-1);

////////////////////////////////////////////////////////
cout << "\nThe list of the results and grades are: " << endl;

for ( i= 1; i < total_times; i++)

cout << "Result " << i << ": " << score[i] << "\t  Grade: " << grade[i] << endl;

//////////////////////////////////////////////////////////

//calc_average function for beautiful clean code
cout << "\nThe Average of the results = " << calc_average(sum,resultNum) << endl;
cout << "The Lowest of the results = " << low << endl;
cout << "The Highest of the results = " << high << endl;
return 0;
}
``````
``````#include <iostream>
#include <iomanip>
using namespace std;

// Function prototype
double score[10];

double resultNum = 0;
int i = 1; // for visual appeal
int total_times =1;
double avg = 0;
double sum = 0;
double high = 0;
double low = 100;

double jjj;
double calc_average(double sum, double num)
{
return (sum/num);
}

void letter(double score, double resultNum, int i)
{
if (score<60)
{
cout << "Result " << resultNum << " is a U\n" << endl;
}
if (score>=60 && score<70)
{
cout << "Result " << resultNum << " is a C\n" << endl;
}
if (score>=70 && score<90)
{
cout << "Result " << resultNum << " is a B\n" << endl;
}
if (score>=90)
{
cout << "Result " << resultNum << " is a A\n" << endl;
}

}

int main()
{
do
{
cout << "Enter result " << i << " (or -1 if no more results) ";
cin >> score[i];
jjj = score[i];
if(score[i]!=-1)
{
sum=sum+jjj; //save inputs before continuing
if (jjj>high)
high = jjj; //check for high grades

if (jjj<low)
low = jjj; //check for low grades

resultNum++; //used to divide average

i++;
total_times = i;
}
}while (score[i] !=-1);

////////////////////////////////////////////////////////
cout << "\nThe list of the results and grades are: " << endl;

for ( i= 1; i < total_times; i++)

cout << "Result " << i << ": " << score[i] << "\t  Grade: " << grade[i] << endl;

//////////////////////////////////////////////////////////

//calc_average function for beautiful clean code
cout << "\nThe Average of the results = " << calc_average(sum,resultNum) << endl;
cout << "The Lowest of the results = " << low << endl;
cout << "The Highest of the results = " << high << endl;
system("pause");
return 0;
}
``````

Thank you very much. You solved my problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.