I am getting the error "expected unqualfied-id before 'if'" on lines 49 and 54. I tried to fix it but I got stuck. Anyone know the cause of the problem?
elseif(gWeapon > 51 && gWeapon < 100)
{
std::cout << "You missed, sorry!" << endl;
std::cout << "Better luck next time!" << endl;
}
} //This brace is the closing brace for main
if (YN == 2)
{
std::cout << "Throwing... ";
gWeapon=rand()%100+1;
}
if (YN == 3)
{
std::cout << "Throwing... ";
gWeapon=rand()%100+1;
}
Remove the extra closing brace form right before if (YN == 2)
And I don't think those block is going to do what you want it to
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
if (YN == 1)
{
std::cout << "Throwing... ";
Sleep(400);
gWeapon=rand()%100+1;
if(gWeapon > 0 && gWeapon < 50)
{
std::cout << "Congratulations, you made it!" << endl;
std::cout << "You've gained 10 points!";
system("pause");
goto retry;
}
} //This brace just closed the if (YN == 1) block
elseif(gWeapon > 51 && gWeapon < 100)
{
std::cout << "You missed, sorry!" << endl;
std::cout << "Better luck next time!" << endl;
}
That elseif isn't being associated with if (gWeapon > 0 && gWeapon < 50), it'll be associated with if (YN == 1)
Unless that's what you intended, then disregard that, but your indentation suggests you wanted it to be associated with if(gWeapon > 0 && gWeapon < 50)