So, I got 2 functions and both are basically playing a game named "Pig Game" and the code below is int main() in my code and it just prints the main things and after it starts the functions one by one. Also, there is another function named roll_a_dice() you can ignore it, it basically rolls a dice.
For example in the first while loop play_computer starts first and play_user second. The loop repeats 6 times. And what I need is after every round, I need to get the result (or output, or return) of the functions and put it in another function named scoresheets(). And I have no idea how to do it. Help me, please.
int main(void){
int roll, comp, me, round=1;
srand(time(NULL));
printf("Welcome to Big Pig game.");
printf("\nLets get started!");
comp = roll_a_dice();
printf("\nI have rolled the dice and got %d!",comp);
printf("\nShall i roll the dice for you (Y/N)? ");
scanf("%c",&roll);
if (roll=='Y'){
me=roll_a_dice();
printf("I have rolled the dice for you and you got %d!",me);
if (comp>me){
while (round<=6){
printf("\nRound %d--My Turn: ",round);
printf("\n===================================================================================");
printf("%d",play_computer());
printf("\nRound %d--Your Turn: ",round);
printf("\n===================================================================================");
printf("%d",play_user());
round++;
}
}
else{
while (round<=6){
printf("\nRound %d--Your Turn: ",round);
printf("\n===================================================================================");
printf("%d",play_user());
printf("\nRound %d--My Turn: ",round);
printf("\n===================================================================================");
printf("%d",play_computer());
round++;
}
}
}
printf("%d",scoresheet());
return 0;
}
Aucun commentaire:
Enregistrer un commentaire