Coin Toss using Function

Hello I am trying to a simple coin toss program using a function. I have seen similar ones done by other users and I created this one as practice for my c++ class. However I seem to have ran into a bit of unknown situation that I am unable to figure out how to fix.

This error keeps popping up:
C-Toss.cpp (.text+0x4e): undefined reference to `coinToss()'

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
#include<iostream>
#include<ctime>
#include<cstdlib>
#include<cmath>

using namespace std;

int coinToss();

int main()
{
	int toss=0;
	char r;
	
	cout << "How many tosses: ";
	cin >> toss;
	
	srand(time(0));
	
	while(toss > 0)
	{
		r = coinToss();
		
		if(r == 1)
		{
			cout << "Heads";
		}
		else if(r == 2)
		{
			cout << "Tails";
		}
		
		toss--;
	}
	
}

int cointToss()
{
	int c_num;
	c_num=(rand()%2)+1;
	
	return c_num;
}
Line 38: Check your spelling.
Last edited on
LOLLLLL, Thank You, for some reason I have trouble catching small stuff like that :)
Topic archived. No new replies allowed.