Hi programmers!
I'm new at c++ and i want help about a simple guessing number game.
I want:
I post the code i have already write. Because i am new, any help are welcome!
- the player has 3 tries (the number is between 0 and 20)
- if player doesnt guess the right number, then the programm will close
- if the player guess the right number then print "congrats" and ask the player if he want a new game.
Code:#include <stdio.h>#include <stdlib.h> main() { int x; int guess; int tries; char answer; do x = rand(); while ( x < 0 || x > 20 ); tries=0; do do do printf("Put your guess from 0 to 20 please;"); scanf("%d",&guess); while ( guess < 0 || guess > 20 ); tries=tries+1 if (guess==x) printf ("Congratulations, you guess the right number. Do you want play again?"); scanf("%s", answer); else printf ("wrong number!"); while tries=3 while (answer!=no); }
Thank you very much.



LinkBack URL
About LinkBacks



