Hello,
When I run my code below, it lets me pick a number and seems to go through my first IF statement fine. However, after I get through my first IF, I'm wanting it to then add to my tries so that when I go over 5 or more tries, I exit. It seems that it's ignoring my tries++ IF statment and only allows me to guess one time. Can someone take a look at this, I may have just banged my head too many times on this and just missing something right there... Thanks
#include <stdio.h>
#include <stdlib.h>
int main()
{
int num = 0;
int tries = 0;
int randomNumber = rand()%100;
printf(" Enter a number between 1 and 100\n");
scanf("%d", &num);
printf("\n");
{
if(num == randomNumber)
{
printf("You WIN!!!\n");
}
else
if (num < randomNumber)
{
printf("Too LOW!!!\n");
}
else
printf("Too HIGH!!!\n");
}
tries++;
if (tries >=5)
{
printf("Too many tries, you lose!!!\n");
}
printf("\n\nEND PROGRAM!\n\n");
system("PAUSE");
return 0;
}