Hello, I am trying to build a program that outputs how many years it takes for population of town A to be greater than or equal to town B's.
This is the error it is giving me:
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>c:\users\sleek super beast\documents\visual studio 2010\Projects\HWch5\Debug\HWch5.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.
I am wondering if my if else statements are incorrect and that is the reason for the error code, I have never seen it before. Any sort of help would be greatly appreciated, thanks!
#include <iostream>
usingnamespace std;
int main()
{
int years = 0;
int popA, popB, newpopA, newpopB, growA, growB;
cout << "Enter the current population of town A: ";
cin >> popA;
cout <<endl;
cout << "Enter the current population of town B: ";
cin >> popB;
cout << endl;
cout << "Enter the growth rate of town A:";
cin >> growA;
cout << endl;
cout << "Enter the growth rate of town B:";
cin >> growB;
cout << endl;
double newrateA = growA/100.00, newrateB = growB/100.00;
while (popA < popB)
{
if (growA > 0 && growA < 1)
{
newpopA = popA * growA;
popA = popA + newpopA;
}
if (growA >= growB)
{
newpopA = popA * newrateA;
popA = popA + newpopA;
}
else
{
cout << "Invalid growth rate for town A, must be larger than town B's.";
break; //Should I put a return statement to re input values??
}
if (0 < growB && growB < 1)
{
newpopB = popB * growB;
popB = popB + newpopB;
}
if (0 <= growB)
{
newpopB = popB * newrateB;
popB = popB + newpopB;
}
else
{
cout << "Invalid growth rate for town B.";
break;
}
years++;
}
if (popA >= popB)
{
cout << "After " << years << " year(s) the population of town A will be greater than or equal to the population of town B" << endl;
cout << "After " << years << " population of town A is:" << popA << endl;
cout << "After " << years << " population of town B is:" << popB << endl;
}
system ("pause");
return 0;
}