This program compiles correctly but when I go to run it I get two errors. They are:
Error 1 error LNK2019: unresolved external symbol "double __cdecl kenteicEntergy(double,double)" (?kenteicEntergy@@YANNN@Z) referenced in function _main
Error 2 error LNK1120: 1 unresolved externals
If you can tell my how to fix and what the errors means exactly that would ne a great help thank you in advance.
This program uses a function named kineticEntergy
that accepts mass and velocity as arguments. The
function should then return teh amoun of kinetic
entergy the object has. Demonstrate tge function
call by calling it asking the user for input.
*/
#include <iostream>
#include <cmath>
usingnamespace std;
//Function Prototype.
double kenteicEntergy(double mass, double velocity);
int main()
{
//Variables.
double mass, velocity;
char again;
//Do while loop.
do
{
//Cout statements asking for user input.
cout << "Kenetic Energy Calculator." << endl;
cout << "What is the objects mass in kg. ";
cin >> mass;
cout << "What is the velocity of the object. ";
cin >> velocity;
cout << "The kenetic energy is " << kenteicEntergy(mass, velocity) << " Joules.";
//Aks if the user would like to try again.
cout << "Would you like to try again? (y or n)";
cin >> again;
} while (again == 'y' || again == 'Y');
system("pause");
return 0;
}
/**************************************************************
* keneticEnergy Function *
* This function will calculate the kenetic energy. This *
* function accepts an pbjects mass and velocity as arguments. *
* The function will then return the amount of kenetic energy *
*the object has. *
***************************************************************/
double keneticEntergy(double mass, double velocity)
{
double kE;
kE = 1.0 / 2.0 * mass *pow (velocity, 2);
return kE;
}
Your prototype is called kenteicEntergy but your function at the bottom is called keneticEntergy. Try renaming the function at the bottom so the names match.
Only one error. From the linker. The linker sees that the main() calls function double kenteicEntergy(double, double), but there is no implementation for that function anywhere.
Thank you. That is two programs that I have had in a row that a typo kept me from completing without help. I guess sometimes you just need fresh to see what you are missing.