Here is my program with the errors any help would be appreciated.

error C3861: 'headTail': identifier not found, even with argument-dependent lookup

error C3861: 'results': identifier not found, even with argument-dependent lookup

error C2365: 'headTail' : redefinition; previous definition was a 'formerly unknown identifier'

error C2365: 'results' : redefinition; previous definition was a 'formerly unknown identifier'

Program:

#include <iostream>
using namespace std;


int getRandom();
voidHeadTails(int &random, int &count);
voidResults(int &count);

int main ()
{
    cout << "        Name" << endl << endl;

    srand(time(0));
    int random;
    int count = 0;

    for (int count2 = 1; count2 <= 100; count2++)
    {
        random = getRandom();
        headTail(random,count);
    }

    results(count);

    cout << "\n\n";
    return 0;

}



int getRandom()
{
    int random;
    random = rand() % 2;

    return random;
}


void headTail(int &random, int &count)
{
    if (random == 0)
    {
        cout << "Heads" << endl;
    }
    else
    {
        cout << "Tails" << endl;
        count ++;
    }

}


void results(int &count)
{
    int tails;
    tails = (100 - count);
    cout << "The coin landed on HEADS " << count << " times.\n";
    cout << "The coin landed on TAILS " << tails << " times.\n";
}

Recommended Answers

All 2 Replies

Sorry jumped the gun a little bit. I fixed the problem. Thanks any ways!!!

Plz use code tags from next time

C++ is a case sensitive language....and u need to include <ctime> for time().....Here's is your corrected code...red coloured lines had problem

#include <iostream>
#include<ctime>//added this header
using namespace std;


int getRandom();
void headTail(int &random, int &count);
void results(int &count);

int main ()
{
cout << " Name" << endl << endl;

srand(time(0));
int random;
int count = 0;

for (int count2 = 1; count2 <= 100; count2++)
{
random = getRandom();
headTail(random,count);
}

results(count);

cout << "\n\n";
return 0;

}



int getRandom()
{
int random;
random = rand() % 2;

return random;
}


void headTail(int &random, int &count)
{
if (random == 0)
{
cout << "Heads" << endl;
}
else
{
cout << "Tails" << endl;
count ++;
}

}


void results(int &count)
{
int tails;
tails = (100 - count);
cout << "The coin landed on HEADS " << count << " times.\n";
cout << "The coin landed on TAILS " << tails << " times.\n";
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.