|
|
Write a program for a match-stick game between the computer and
a user.
|
|
#include <stdio.h> int main(void) { int sticks = 21, upick; do { printf( "\nSticks on board : %d ", sticks ); printf( "\nMake your pick [1-4] : " ); scanf( "%d", &upick ); if( upick < 1 || upick > 4 ) { printf( "\No cheating please !!" ); continue; } printf( "\nYou Picked %d\nI pick %d", upick, (5-upick) ); sticks -= 5; } while( sticks > 1 ); printf( "\nYou pick the last stick. You LOOSE" ); printf( "\nThanks for playing. Better luck next time" ); return 0; } |
|
|
|
|
|
|
|