I am getting an error code
Error 2 error C2082: redefinition of formal parameter 'flip'
when I try to build and run my program. Any advice on where I am going wrong here?
//CHAPTER SIX PROGRAMMING CHALLENGE EIGHT
#include <iostream>
#include<ctime> //FOR RAND AND SRAND
#include<cstdlib> //FOR TIME FUNCTION
usingnamespace std;
//FUNCTION PROTOTYPE
int coinFlip(int);
constint heads = 1;
constint tails = 2;
//MAIN FUNCTION
int main()
{
srand((unsigned)time(0)); //SEED THE RANDOM NUMBER GENERATOR
int tosses, count; //VARIABLE DEFINED
count = 0;
cout << "How many tosses should be made?" << endl; //ASK USER FOR INPUT
cin >> tosses;
while (count <= tosses) //RUN LOOP WHILE LESS THAN TOSSES INPUTED
{
coinFlip();
count++;
}
system("pause");
return 0; //END CODE
}
//FIRST FUNCTION/FLIP FUNCTION
int coinFlip()
{
int flip = (rand()%2)+1; //CALCULATE EITHER 1 OR 2
if (flip == HEADS)
cout << "Heads!.\n"; //DISPLAY HEADS IF 1
elseif (flip == TAILS)
cout << "Tails!.\n"; //DISPLAY TAILS IF 2
return flip; //END FLIP FUNCTION
}