I'm trying to make program that let the user try to guess the letter that the program choose randomly. The loops and the if statements seem not working. If anybody could check my code a little bit it would be awesome.
I'll attach a pic of the output.
int main()
{
srand(time(NULL));
char randlett, playerlett;
int tries = 0;
randlett = rand() % 26 + 97;
printf("The program choose a letter\n\n");
while (tries < 5){
printf("Try number %d\nPick a letter\n", tries + 1);
scanf("%c", &playerlett);
if (randlett != playerlett){
if (playerlett > randlett){
printf("\nThe letter is before the one you chosen\n");
}
else{
printf("\nThe letter is after the one you chosen\n");
}
tries ++;
continue;
}
else{
printf("You win");
break;
}
}
return 0;
}