I'm new to C++ and have been staring at my (probably abysmal) code for a while and can't figure out what's off about it.
I'm trying to loop through a few iterations of if and else statements and must be doing something grammatically incorrect - as it shows compiler errors of 'else without a previous if'
This is for a class and I'm trying to work it out, but if you see something obvious that I am overlooking I would love to know.
Thank you!
for (i = 0; i < iterationsNum; i++){
if (charlieAlive == 0) // Aarron's shot
{
if (aaronShot() == 1)
charlieAlive = 1;
}
else (charlieAlive == 1 && bobAlive == 0);{
if (aaronShot() == 1)
bobAlive = 1;
}
else (charlieAlive == 1 && bobAlive == 1 && aaronAlive == 0);{
cout << "Aaron is the Winner!\n";
totalShot++;
aaronCounter++;
}
continue;
if (charlieAlive == 0 && aaronAlive ==0) // Bob's shot
{
if (bobShot() == 1)
charlieAlive = 1;
}
else (charlieAlive == 1 && aaronAlive == 0);{
if (bobShot() == 1)
aaronAlive = 1;
}
else (charlieAlive == 1 && aaronAlive == 1 && bobAlive == 0);{
cout << "Bob is the Winner!\n";
bobCounter++;
totalShot++;
}
continue;
if (charlieAlive == 0 && bobAlive == 0) // Charlie's shot
{
bobAlive = 1;
}
else (charlieAlive == 0 && bobAlive == 1 && aaronAlive == 0);{
aaronAlive = 1;
totalShot++;
}
else (charlieAlive == 0 && bobAlive == 1 && aaronAlive == 1);{
cout << "Charlie is the Winner!\n";
}
continue;