Menu

[Solved]Covert Following Program C Int Main Srand Time 0 Int Playagain Int Playerscore 0 Int Compu Q37185753

Covert following program to C

int main()
{
srand(time(0));
int playAgain;
int PlayerScore=0;
int computerScore= 0;
int ties= 0;
do
{
system(“CLS”);
Firstturn = rand()%(2-1+1)+1;// starting person.
ComputerRandomPosition= rand()%(9-1+1)+1;// computer firstpick-
random
gameWin=3;
block1= ‘1’;
block2= ‘2’;
block3= ‘3’;
block4= ‘4’;
block5= ‘5’;
block6= ‘6’;
block7= ‘7’;
block8= ‘8’;
block9= ‘9’;
//start of program
cout<<“Welcome to Tic Tac ToeGame”<<endl<endl;
cout<<“Player:”<<playerScore<<“Computer:”<<computerScore<<“Ties:”<<ties<<endl;
if(Firstturn==1)// player first
{
cout<<“Please Select your a grid to place(X):”<<endl<<endl;
Borad_of_GAME();
while(!(cin>>Choice_Of_The_player))//Store letter
{
cout<<endl;
cout<<“Numbers only.”<<endl;
}
checkPlayerinput();
//system(“CLS”);
Borad_of_GAME();
TurnPlayer= false;// switches to CP
}
if(Firstturn == 2) // CP first
{
ComputerRandomPosition;
computerPick = ComputerRandomPosition;
checkComputerinput();
cout<<“The computer is choosing…n”,,endl;
TurnPlayer = true;
Borad_of_GAME();
}
do
{
if(TurnPlayer == true)// player loop
{
cout<<“Please choose a grid toplace(X):”<<endl<<endl;
while(!(cin>> Choice_Of_The_player))// error
{
cout<<endl;
cout<<“Numbers only.”<<endl;
cin.clear();
cin.ignore(10000,’n’);
}
checkPlayerinput();
checkWinPlayer();
checkTie();
TurnPlayer = false;
}
if(TurnPlayer == false)//computer loop
{
ArtificalComputer();
Borad_of_GAME();
CheckComputerWin();
checkTie();
TurnPlayer= true;
}
}
while(gameWin>2);
if(gameWin == 0)
{
cout<<“The game is a Tie!”<<endl;
++ties;
}
if(gameWin == 1)
{
cout <<“The player wins!” << endl;
++playerScore;
}
if(gameWin == 2)
{
cout<<“The computer wins!”<< endl;
++computerScore;
}
cout<<“Player:”<<playerScore<<“”<<“Computer”<<computerScore<<“Ties:”<<ties<<endl;

cout<<“Play again?n1. Yeesn2. Non”<<endl;
while(!(cin>>playAgain))
{
cout<<endl;
cout<<“Play again?n1. Yesn2.Non”<<endl;
cin.clear();
cin.ignore(10000,’n’);
}
}
while(playAgain == 1);
return 0;
}

Expert Answer


Answer to Covert following program to C int main() { srand(time(0)); int playAgain; int PlayerScore=0; int computerScore= 0; int t… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *