What is wrong with this program?

what i'm trying to make here is the classic dice game pig
i realize that the program is unfinished, i did not add the computer's choice to take another turn or to hold, and i am not asking you to finish it for me

now, what happens when i build this program is that i get a blank screen and nothing else, could you please tell me what's wrong with my code?

additionally, if you could tell me how to make my code all spaced out and easy to read, i think that would be beneficial to all of us

than you very much =)


#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;

int humanTurn(int Humantotalscore);
int computerTurn(int Computertotalscore);
int roll ();
int turn = 0;
int d = 0;

int main ()
{
srand(time(NULL));
int Humantotalscore = 0;
int Computertotalscore = 0;

while ((Humantotalscore < 100) && (Computertotalscore <100));
{
turn = turn +1;

cout << "turn: " << turn <<endl;
cout << "You: " << Humantotalscore << " Computer: " << Computertotalscore <<endl;

}


if ((Humantotalscore >= 100) && (Computertotalscore <100))
cout << "congradulations you win!" << endl;
cout << " =D\n";

if ((Computertotalscore >= 100) && (Humantotalscore < 100))
cout << "sorry, you have lost" <<endl;
cout << " =(\n";
return 0;
}

int roll (int d)
{

return d = (rand() %6 +1);
}

int humansTurn(int Humantotalscore = 0)
{
int Humanscorethisturn = 0;
char choice;


Humanscorethisturn = d;

if (d <= 2)

while (choice = 'y');
{
cout << "You have rolled a number between 2 and 6 would you like to roll again? ";
cin >> choice;

(Humanscorethisturn = d + Humanscorethisturn);
}

if (d == 1)
{
(Humanscorethisturn = d);
cout << "You have rolled a 1, End of turn";
}

return Humantotalscore = Humanscorethisturn + Humantotalscore;
}

int computersTurn(int Computertotalscore)
{
int Computersscorethisturn = 0;
char choice;



Computersscorethisturn = d;

if (d >1)
{
Computersscorethisturn = Computersscorethisturn + d;
}

else
{
Computersscorethisturn = d;
cout << "The computer has rolled a 1, End of turn";
}

return Computertotalscore = Computersscorethisturn + Computertotalscore;
}
You should pay extra close attention to your while statement! Your error is there, in fact it is the very last character on that line. You don't end a while statement with a semi-colon. The compiler generally won't see it as an error, sometimes a warning if you set up the compiler that way, because it sees it that you are just ending the code rather then making a error. Take out the semi-colon and that should help you move forward in your program development.
ooooooh thank you very much =D
i kinda rushed this project so i guess i just put a semi-colon after every single line

thanks again =)
Topic archived. No new replies allowed.