Question: #include #include #include #include #include int getTheNumberOnTheDice(){ int sum = 0; srand(time(NULL)); sum+= rand() % 6 + 1; sum+= rand() % 6 + 1; return

#include

#include

#include

#include

#include

int getTheNumberOnTheDice(){

int sum = 0;

srand(time(NULL));

sum+= rand() % 6 + 1;

sum+= rand() % 6 + 1;

return sum;

}

void main(){

clrscr();

int ph = 100;

int eh = 100;

int num = 0;

int i = 1;

do {

num = getTheNumberOnTheDice();

printf ("[ Round %d ] -- The number on the dice is %d ", i, num);

if (num < 7) {

ph -= 20;

}

if (num > 6) {

eh -= 20;

}

printf("Player's current health --> %d ", ph);

printf("Enemy's current health --> %d ", eh);

sleep(1);

i++;

} while ((ph > 0) && (eh > 0));

if (ph > eh){

printf("You win ");

} else

printf("You lose ");

getche();

}

Create a simplified and shorter version of this code. ( CODE MUST BE IN C AND TRY TO MAKE WITHOUT USING sleep command and time.h library and unistd.h library )

Original Question was Create 2 dice Game using C Language. When game starts, Player`s health will be 100 & enemy`s health will also be 100. When 2 dice is roll and if sum of these dice is less than 7 then player`s health will be decreases 20 points. Thats mean total health of player will be 80 points. When 2 dice is roll and if sum of these dice is greater than 6 then enemy`s health will be decreases 20 points. That`s means total health of player will be same but the total health of enemy will be 80 points. In the end of program message will be shown either You win or You lose.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!