/* RepeatableGame.c (c) Kari Laitinen http://www.naturalprogramming.com 2013-11-21 File created. 2013-11-21 Last modification. This is a repeatable version of the 'game' that is presented in Game.c. */ #include #include /* Definitions for bool, true, and false */ int main() { bool user_wants_to_play_more = true ; while ( user_wants_to_play_more == true ) { printf( "\n This program is a computer game. Please, type in " "\n an integer in the range 1 ... 2147483646 : " ) ; char given_integer_as_string[] = "000000000000000000" ; gets( given_integer_as_string ) ; int integer_from_keyboard = atoi( given_integer_as_string ) ; int one_larger_integer = integer_from_keyboard + 1 ; printf( "\n You typed in %d" "\n My number is %d" "\n Sorry, you lost. I won. The game is over. \n", integer_from_keyboard, one_larger_integer ) ; ; printf( "\n You want to play more (Y/N) ? " ) ; char user_choice[] = "??????" ; gets( user_choice ) ; if ( strlen( user_choice ) == 0 ) { user_wants_to_play_more = false ; } else if ( user_choice[ 0 ] != 'Y' && user_choice[ 0 ] != 'y' ) { user_wants_to_play_more = false ; } } } /* NOTE: Old C compilers do not know the stdbool.h file, and they do not accept variable declarations between action statements inside a function. */