Help!

Hey guys, i've been working on this program for a while now and i have a few errors i need help on. It may just be because i've been looking at it over and over again. But if anyone can give me any answer on how to make it work, please help! Thanks!
My Code Is:
#include <iostream>
#include <string>
#include <vector>
#include <time.h>

using namespace std;
double cellDivide(int maxGeneration, double numberofCells);
int getnumberofDividedCells(int generation);
bool cancer = false;

int main()
{
int generations;

srand(static_cast<unsigned int> (time(0)));
cout << "Enter the number of generations: ";
cin >> generations;
double numberofCells = 1;

numberofCells = cellDivide(generations, numberofCells);

double expectednumberofCells = pow(2, generations);

cout << fixed << "Actual" << numberofCells << endl;
cout << fixed << "Expected" << expectednumberofCells << endl;

if (expectednumberofCells = numberofCells)
{
cout << "No Cancer! " << endl;
}
else
{
cout << "Yoy have " << numberofCells - expectednumberofCells << "Cancerous cell" << endl;
}
system("PAUSE");
return 0;

int maxGeneration;
double prevnumberofcells = numberofCells;
for (int i = 1; i < maxGeneration; i++)
{
cout << maxGeneration << endl;
{
return 0;

int getnumberofdividecells(int generations);
{
if (cancer)
return 3;
int odds = 1;

if (generations <= 25)
odds = 1000;
else if (generations < 40)
odds = 500;
else if (generations < 50)
odds = 100;
else
odds = 25;

int choice = rand() % odds;
{
if (choice == 0)
{
cancer = true;
return 3;
}
else
{
return 2;
}
}
}
}
}
return 0;
}

When I run I get errors: LNK1120 (2 unresolved externals, line 1)

Error LNK2019 unresolved external symbol "double __cdecl cellDivide(int,double)" (?cellDivide@@$$FYANHN@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)

Severity Code Description Project File Line Suppression State
Error LNK2028 unresolved token (0A000532) "double __cdecl cellDivide(int,double)" (?cellDivide@@$$FYANHN@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)

Please and thank you!

Please put code into code tags so that we are able to read it, click edit and click the things that look like this <> and put the code in there.

However looking at it, I see an error. Look at your prototype, getnumberofDividedCells and now look at your definition name. They are different, change that as it is an error, not only that but you added a semicolon at the beginning of the function.

Another thing is you never even defined cellDivide(int maxGeneration, double numberofCells) anywhere in your code, yet you are calling it in main, the 6th statement in there.
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
76
77
#include <iostream>
#include <string>
#include <vector>
#include <time.h>

using namespace std;
double cellDivide(int maxGeneration, double numberofCells);
int getnumberofDividedCells(int generation);
bool cancer = false;

int main()
{
int generations;

srand(static_cast<unsigned int> (time(0)));
cout << "Enter the number of generations: ";
cin >> generations;
double numberofCells = 1;

numberofCells = cellDivide(generations, numberofCells);

double expectednumberofCells = pow(2, generations);

cout << fixed << "Actual" << numberofCells << endl;
cout << fixed << "Expected" << expectednumberofCells << endl;

if (expectednumberofCells = numberofCells)
{
cout << "No Cancer! " << endl;
}
else
{
cout << "Yoy have " << numberofCells - expectednumberofCells << "Cancerous cell" << endl;
}
system("PAUSE");
return 0; 

int maxGeneration;
double prevnumberofcells = numberofCells;
for (int i = 1; i < maxGeneration; i++)
{
cout << maxGeneration << endl;
{
return 0;

int getnumberofdividecells(int generations);
{
if (cancer)
return 3;
int odds = 1;

if (generations <= 25)
odds = 1000;
else if (generations < 40)
odds = 500;
else if (generations < 50)
odds = 100;
else
odds = 25;

int choice = rand() % odds; 
{
if (choice == 0)
{
cancer = true;
return 3;
}
else
{
return 2;
}
}
}
}
}
return 0; 
}
Okay I see two more errors, first of all you are trying to use pow on line 22 yet you never included <cmath>. So please include that.

Another one is on line 27, I believe you were trying to check for equality rather than assign a value. If so change too double == because right now that isn't a condition.
Topic archived. No new replies allowed.