Creat a game of 4 donkey in c programing, The game will be a text based game that shows the donkeys being transferred. The game should begin by displaying how many donkeys are in which stable as well,The game will begin by asking the player which donkeys will be sent to the other stable. Donkeys are labeled 1 to 4. Should the player wish not to send a donkey, the player can put 0 (zero) instead. When the game is completed, the game will display to the player if the route taken was fast or not. If the time it took for all the donkeys to be transferred is over 13 hours, then that is regarded as slow. Otherwise, this should be regarded as fast.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int s1, s2, s3, s4, u1, u2, u3, u4;
printf("Welcome to The Donkey Game\nThe adventure begins here.......\n");
s1 = rand()%20 + 1;
printf("In the first stable there are %d donkeys.\n", s1);
printf("How many donkeys do you want to send? ");
scanf("%d", &u1);
s2 = rand()%20 + 1;
printf("In the second stable there are %d donkeys.\n", s2);
printf("How many donkeys do you want to send? ");
scanf("%d", &u2);
s3 = rand()%20 + 1;
printf("In the third stable there are %d donkeys.\n", s3);
printf("How many donkeys do you want to send? ");
scanf("%d", &u3);
s4 = rand()%20 + 1;
printf("In the fourth stable there are %d donkeys.\n", s4);
printf("How many donkeys do you want to send? ");
scanf("%d", &u4);
int total = u1 + u2 + u3 + u4;
if (total < 13) {
printf("This will take %d hours to send which is very preferable.", total);
} else {
printf("This will take %d hours. which is slow.", total);
}
return 0;
}
Comments
Leave a comment