Matchstic Game

#include <stdio.h>
int main(){
int match = 21, comp, user, choice, c = 0;
printf(“Game Rules:\nYou have to pick 1, 2, 3 or 4 matchstick at a time.”);
printf(“\nAfter your picking, computer does its picking.”);
printf(“\nWhoever is forced to pick the last matchstick looses the game.”);
printf(“\nPress 1 to start the game:”);
scanf(“%d”, &choice);
while (choice == 1) {
do {
printf(“\nPick any number of matchstick:”);
scanf(“%d”, &user);
if (user > 4) {
printf(“You picked more than 4 stick, you loose.\n”);
c++;
break;
}
match = match — user;
comp = 5 — user;
printf(“\nComputer picks %d matchstick.\n”, comp);
match = match — comp;
} while (match > 1);
if (c == 0) {
printf(“\nYou picked the last matchstick, so you loose.\n”);
break;
}
break;
}
}
Show your support

Clapping shows how much you appreciated Pratik Sah’s story.