Loop Structure

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!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <iostream>

using namespace 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;
}


compiled just fine for me....
Copypaste the code into a new blank/empty project. The project you made this code in is screwed.
i copy-pasted it to my new file and it worked perfectly
Were you using Visual Studio 2010? I've noticed a slight bug where it can't find the libraries from time to time, so I have to create a new file.
Topic archived. No new replies allowed.