I'm at work, on lunch time, can't go in IRC here so I registered to the forum.
Well, since I started learning C the other day, I thought it was pretty cool... I went through a few things, and just learned about loops. (*EDIT: Forgot to mention the language... it's C )
So, this post is to ask if you cuold shed me some light, without giving me the code right away, you see my little game below; I want to upgrade it.
If you can give me a well detailed picture, I would appreciate since I need to learn, so neither a direct asnwer or formula would do.
I want:
1) The program to count the number of times the user tried a number before finding the random one.
printf("Contrats, after % number of times, you found it", variable)
2) I want the program to ask if the user want to try another game, using booleen (always true, false = endgame)
and 3rd) I want it to be a 2 players game, someone enters the "random" number, and the other person tries to find it... BUT! We MUST be able to choose wether its gonna be a 1 player (random generated number) or 2 players.
I need some help from you coders
Code: Select all
/*
Less or More Mini-game-------------
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main ( int argc, char** argv )
{
int guessNumber = 0, inputNumber = 0;
const int MAX = 100, MIN = 1;
// Generating the random number
srand(time(NULL));
guessNumber = (rand() % (MAX - MIN + 1)) + MIN;
/* Loop of the program. It repeats until the user finds the guessNumber
*/
do
{
// It asks for the number
printf("What is the number ? ");
scanf("%d", &inputNumber);
// We compare the input number with the guessNumber
if (guessNumber > inputNumber)
printf("It's more !\n\n");
else if (guessNumber < inputNumber)
printf("It's less !\n\n");
else
printf ("Congrats, you found the mysterious number !!!\n\n");
} while (inputNumber != guessNumber);
}