[Updated] Guessing game program advice

i have to make a guessing game with a maximum of 10 tries/guesses and also have to display the guesses for the user to see but im once again stuck after redoing it several times and i want to figure what i need to do next assistance is greatly appreciated heres where im at so far also having trouble with syntax errors.


#include <stdio.h>
#include <time.h>
void main ()
{
char icode;
int number;
int guess;
int i=0;
const int GUESSES=10;
for(; ;)
{
printf("Welcome To The Guessing Game\n");
printf("Please press A to Play\nor Q to Quit");
scanf("%c", &icode);
if(icode != 'A' && icode != 'a')
if(icode != 'Q' && icode != 'q')
{
number = rand() % 100+1;
for(int i = 0; i < GUESESS; ++i)
{
printf("Please enter a number from 1-100,\nYou have a maximum of 10 guesses\nGood Luck.");
scanf("%d", &guess);
++i;
if (guess < number)break;
{
printf("My number is higher.\nPlease guess again.");
}
else if (guess > number) break;
++i;
{
printf("My number is lower.\nPlease guess again.");
}
else
{
printf("Correct!!!! It only took you" i "GUESSES.");
CorrectGuess = 1
}
}
if i == 10 &&!CorrectGuess
{
printf("You Lose. The number was" number);
}
}
}
Please use code tags: [code]Your code[/code]
Read this: http://www.cplusplus.com/articles/z13hAqkS/

Compare this if i == 10 &&!CorrectGuess and e.g. if(icode != 'A' && icode != 'a'). Do you see a difference.

1
2
3
4
5
if (guess < number)break; // The if clause ends here.
{ // The following printf does not belong to if (guess < number)
printf("My number is higher.\nPlease guess again.");
}
else if (guess > number) break;  // The else clause does not refer to any if. 


You have i twice:
1
2
3
4
5
6
7
int i=0; // First i
...
for(int i = 0; i < GUESESS; ++i) // Second i
{
printf("Please enter a number from 1-100,\nYou have a maximum of 10 guesses\nGood Luck.");
scanf("%d", &guess);
++i; // Which i you're referring to? 
Topic archived. No new replies allowed.