In my math programming class I have an assignment to find the slope intercept formula (y2 - y1) / (x2 - x1) which is the m of the formula y = mx + b.

I have to find 2 slope intercept equations and make an if-statement or multiple if-statements to see if the lines intercept, don't intercept, or are the same line. Pretty easy right? I have 2 error LNK2019 errors. There are my errors and my program is copy pasted underneath. Can anyone help me out please??

1>main_program.obj : error LNK2019: unresolved external symbol "float __cdecl Other_Slope_intercept_formula(float *,float *)" (?Other_Slope_intercept_formula@@YAMPAM0@Z) referenced in function _main

1>main_program.obj : error LNK2019: unresolved external symbol "float __cdecl Slope_intercept_formula_of_the_lines(float *,float *)" (?Slope_intercept_formula_of_the_lines@@YAMPAM0@Z) referenced in function _main

1>c:\users\zvjezdan\documents\visual studio 2010\Projects\project2_gamephysics\Debug\project2_gamephysics.exe : fatal error LNK1120: 2 unresolved externals

``````#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
int formula1[2];
int formula2[2];
int formula3[2];
int formula4[2];
int B, b;
cout << "Welcome to the program.  ^_^" << endl;
cout << endl;
cout << "What is the X number for the first slope intercept formula? ";
cin >> formula1[0];
cout << endl;
cout << "What is the Y number for the first slope intercept formula? ";
cin >> formula1[1];
cout << endl;
cout << "What is the X number for the second slope intercept formula? ";
cin >> formula2[0];
cout << endl;
cout << "What is the Y number for the second slope intercept formula? ";
cin >> formula2[1];
cout << endl;
float Slope_intercept_formula_of_the_lines( float *formula1, float *formula2);
{
cout <<  " The slope intercept formula is (y2 - y1) / (x2 - x1) which is the M in the formula y = mx + b" << endl;
cout << endl;
cout << "That being the case, your Slope Intercept of the First Problem is: " << (formula2[1] - formula1[1]) /(formula2[0] - formula1[0]) << "x" << endl;
cout << endl;
};
cout << "For the formula y = mx + b, your m is: " << Slope_intercept_formula_of_the_lines << "x" << endl;
cout << endl;
cout << "What do you want b to be? ";
cin >> B;
cout << endl;
cout << "What is the X number for the first slope intercept formula? ";
cin >> formula3[0];
cout << endl;
cout << "What is the Y number for the first slope intercept formula? ";
cin >> formula3[1];
cout << endl;
cout << "What is the X number for the second slope intercept formula? ";
cin >> formula4[0];
cout << endl;
cout << "What is the Y number for the second slope intercept formula? ";
cin >> formula4[1];
cout << endl;
float Other_Slope_intercept_formula( float *formula3, float *formula4);
{
cout <<  " The slope intercept formula is (y2 - y1) / (x2 - x1) which is the M in the formula y = mx + b" << endl;
cout << endl;
cout << "That being the case, your Slope Intercept of the First Problem is: " << (formula4[1] - formula3[1]) /(formula4[0] - formula3[0]) << "x" << endl;
cout << endl;
};

cout << "For the formula y = mx + b, your m is: " << Other_Slope_intercept_formula << "x" << endl;
cout << endl;
cout << "What do you want b to be? ";
cin >> b;
cout << endl;

if (Slope_intercept_formula_of_the_lines == Other_Slope_intercept_formula && B == b)
{
cout << "The Lines are the same line. " << endl;
cout << endl;

}
else if (Slope_intercept_formula_of_the_lines == Other_Slope_intercept_formula && B != b)
{
cout << "The lines are parallel." << endl;
cout << endl;
}
else if (Slope_intercept_formula_of_the_lines != Other_Slope_intercept_formula && B == b)
{
cout << "The lines intersect at B." << endl;
cout << endl;
}
else if(Slope_intercept_formula_of_the_lines != Other_Slope_intercept_formula && B != b)
{
cout << "The lines intersect." << endl;
cout << endl;
}
system("pause");
return 0;
}``````

## All 5 Replies

Hmm... So many unknown function calls! Anyway, when an external link error occurs, you need to check if the libraries you include in your program are installed correctly. I don't know about your "algorithm" library.

Also, the line

``````int formula3[2];
...
...
float Other_Slope_intercept_formula( float *formula3, float *formula4);``````

don't seem to be correct. If you declare "formular3" as int array, why do you use it as float pointer? Oh, are you sure that the line is "calling" a function or "declaring" a function? If you are calling a function and pass value by "reference" you need to call it as...

``Other_Slope_intercept_formula(formula3, formula4);  // Please correct me if I'm wrong. Not use C++ for a long time.``

Also, that mean you should declare formular# variables as float array, and the function accept float array variables as well.

I don't think it would work, but I have fixed it. Here is my code.

``````#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
int x1,y1,x2,y2,x3,y3,x4,y4,B,b;
cout << "Welcome to the program.  ^_^" << endl;
cout << endl;
cout << "What is the X number for the first slope intercept formula? ";
cin >> x1;
cout << endl;
cout << "What is the Y number for the first slope intercept formula? ";
cin >> y1;
cout << endl;
cout << "What is the X number for the second slope intercept formula? ";
cin >> x2;
cout << endl;
cout << "What is the Y number for the second slope intercept formula? ";
cin >> y2;
cout << endl;
float slope1((y2 - y1) / (x2 - x1));
cout << "The slope for the first equation is: " << slope1 << "x" << endl;
cout << endl;
cout << "For the formula y = mx + b, your m is: " << slope1 << "x" << endl;
cout << endl;
cout << "What do you want b to be? ";
cin >> B;
cout << endl;
cout << "What is the X number for the first slope intercept formula? ";
cin >> x3;
cout << endl;
cout << "What is the Y number for the first slope intercept formula? ";
cin >> y3;
cout << endl;
cout << "What is the X number for the second slope intercept formula? ";
cin >> x4;
cout << endl;
cout << "What is the Y number for the second slope intercept formula? ";
cin >> y4;
cout << endl;
float slope2((y4 - y3) / (x4 - x3));
cout << "The slope intercept for the second equation is: " << slope2 << "x" << endl;
cout << endl;
cout << "For the formula y = mx + b, your m is: " << slope2 << "x" << endl;
cout << endl;
cout << "What do you want b to be? ";
cin >> b;
cout << endl;
if (slope1 == slope2 && B == b)
{
cout << "The Lines are the same line. " << endl;
cout << endl;

}
else if (slope1 == slope2 && B != b)
{
cout << "The lines are parallel." << endl;
cout << endl;
}
else if (slope1 != slope2 && B == b)
{
cout << "The lines intersect at B." << endl;
cout << endl;
}
else if(slope1 != slope2 && B != b)
{
cout << "The lines intersect." << endl;
cout << endl;
}
system("pause");
return 0;
}``````

Hmm.. You are still using syntax wrong... In line 23 & 43, do you want to declare a variable or a function?

``float slope1((y2 - y1) / (x2 - x1));``

If you want it as a variable, you should do it as

``float slope1 = (y2 - y1) / (x2 - x1);``

The same should be applied to line 43.

Hmm.. You are still using syntax wrong... In line 23 & 43, do you want to declare a variable or a function?

``float slope1((y2 - y1) / (x2 - x1));``

If you want it as a variable, you should do it as

``float slope1 = (y2 - y1) / (x2 - x1);``

The same should be applied to line 43.

There shouldn't be anything wrong with that. It's an explicit variable declaration and initialization, no different than:

``int someInt(15);``

>>...but I have fixed it...
If there is an issue, which I doubt, the issue must be something else.

Be a part of the DaniWeb community

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