Code:
#include <stdio.h>
int main(void)
{
int j=1,n,t,a=43,r; //need to make "a" a random number.
printf("Enter a number:");
scanf("%i",&n);
do {
if (n>a){
r = 5-j;
printf("Your guess was to high guess again (only %i more guesses): ",r);
scanf("%i",&n);
j++;
}
if (n<a) {
r = 5-j;
printf("Your guess was to low guess again (only %i more guesses): ",r);
scanf("%i",&n);
j++;
}
if (n==a) {
printf ("CORRECT!\n");
j=15;
}
}
while (j<5);
if (j>=5 && j<=10){
printf ("To many guesses you lose\n\n");
}
//When guessing all numbers to low or all to high it misses 1 count, it ends on 1 guess left. If it does a "your guess is to low" then a your guess is to high it ends fine.
return 0;
}
Yes I know my code sucks but we all begin some where ? anyways thanks for the help Ill try looking into the random code Adak gave and maybe look into seeding, if you guys have any recommendations please post them, I really want to learn this stuff so all constructive criticism is welcome.