Menu

Include Include Include Include Include Int Getthenumberonthedice Int Sum 0 Srand Time Nul Q43779438

#include <stdio.h>

#include <stdlib.h>

#include <time.h>

#include <conio.h>

#include <unistd.h>

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 %dn”, i, num);

if (num < 7) {

ph -= 20;

}

if (num > 6) {

eh -= 20;

}

printf(“Player’s current health –> %dn”,ph);

printf(“Enemy’s current health –> %dn”,eh);

sleep(1);

i++;

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

if (ph > eh){

printf(“You winn”);

} else

printf(“You losen”);

getche();

}

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

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

Expert Answer


Answer to #include #include #include #include #include int getTheNumberOnTheDice(){ int sum = 0; srand(time(NULL)); sum+= rand() %…

OR