Can anybody gimme an idea as to how this can be done..?
Write a program for a matchstick game being played between the computer and a user.
Your program should ensure that the computer always wins. Rules for the game are as follows:
-There are 21 matchsticks.
-The computer asks the player to pick 1, 2, 3 or 4 matchsticks.
-After the person picks, the computer does its picking.
-Whoever is forced to pick up the last matchstick loses the game.
I tried out some stuff..but as it is..my program was not quite organised..
Code:#include<stdio.h> main() { int matchsticks, total; total = 21; printf("Enter the number of matchsticks you wanna pick up at once:"); scanf("%d", &matchsticks); matchsticks = total - matchsticks; while (matchsticks<= 4) { printf("\n Computer Turn"); /* ...the rest of the program is mystery! */