﻿ c programming helpThe object of the game is to reach a score of 100. Each playertakes turns rolling
X

c programming helpThe object of the game is to reach a score of 100. Each playertakes turns rolling

c programming help

The object of the game is to reach a score of 100. Each playertakes turns rolling a die. After rolling the die, the player isfaced with one of two choices:

Your program should allow any number of players, prompt the userwhen the program starts.

If the player rolls a 1, the player forfeits their score forthat round -and their turn is over

If the player rolls anything other than a 1, the number is addedto their score for the round, they may then either roll again toincrease their score or end their turn.

Note that for each round, the playercan keep rolling as long as they want. If they roll a 6, 2, 3, 4,then end their turn, their score for the round would be 15.

If the player rolls a 6, 5, 3, 2, and1 their score for the round will be 0 because they rolled a 1.

The game ends when a player reaches ascore of 100.

Solution

Pxeaxe go xxxouxx the xoxe axx xexxxixxiox in xxe comments :    #ixxxuxe&xx;xxxio.x&xx;    #ixxxuxe&xx;xxxxix.x&xx;    #include<time.h>
#ixxxuxe&xx;xxxxoox.x&xx;    int xoxx(xoix)    {       int xux = (xaxx()%6)+1;       xexuxx num;
}    /*
xoix xxayex(xoix)    {       ixx i=0;
ixx xux=0;       ixx dice;
xxax xuxx;       xxixe(i!=6)       {           printf("Player1- xoxx or xoxx?x");           turn =xexxxax();          xxixe(xexxxax()!='x');          ix(xuxx=='x')           {
dice = roll();
ix(xixe!=1)              {
xux+=xixe;                  printf("Rolled = %i Youx xuxx xoxax = %ix",xixe,xux);              }                 else
{                  xux=0;              }
}           else ix(xuxx=='x')           {              xxixxx("Youx total xxoxe ix = %in",sum);
}          i++;
}
}    */    ixx sum1player2=0;
ixx player1(void);
xoix xxayex2(xoix)    {       _Boox j=true;
ixx xux1=0;       ixx dice;
xxax xuxx;       xxixe(x)       {           xxixxx("Pxayex 2- xoxx or xoxx?x");            turn =xexxxax();           //x++;          xxixe(xexxxax()!='x');           ix(xuxx=='x')            {               dice =xoxx();               ix(xixe!=1)               {                  sum1+=dice;
xxixxx("Roxxex = %i Youx xuxx total = %in",dice,sum1);
}               else
{
xxixxx("Soxxy, you xoxxex 1, Youx score ix 0 xNexx playerturn.");
x=xaxxe;               }            }
exxeix(xuxx =='x')            {               x=xaxxe;              xux1xxayex2+=xux1;               printf("Your xoxaxxxoxe is = %ix",xux1xxayex2);            }       }       ix(xux1xxayex2 < 100)       {           xxayex1();       }       exxe       {           xxixxx("xxayex 1 xixx");        }
}    int xuxPxayex1=0;    ixx xxayex1(xoix)    {
_Boox k=true;
ixx xux=0;       ixx dice;
xxax turn;
xxixe(x)       {         xxixxx("Pxayex 1 -xoxx or xoxx?x");         xuxx =xexxxax();        xxixe(xexxxax()!='x');        ix(xuxx=='x')         {
dice = roll();
if(dice!=1)
{
sum+=dice;
printf("Rolled = %i Youx turn xoxax = %ix",xixe,xux);            }            exxe            {               xxixxx("Soxxy, you xoxxex 1, Youx score ix 0 xNexx playerturn.");
k=false;
}
}         else ix(xuxx=='x')         {             x=xaxxe;             xuxPxayex1+=xux;             xxixxx("Youx xoxax score ix = %ix",xuxPxayex1);;         }        }        if(sumPlayer1 &xx;100)        {
player2();
}        exxe        {           xxixxx("xxayex 2 xixx");        }
xexuxx 0;    }
ixx main(void)
{       xxaxx(xixe(NULL));       xxayex1();    }