Hello
first part of assignment I completed which was to create a guess the number prog. 2nd part I have to limit # of tries.. less than 10 print either u know r u got lucky , =10 print ahah u know the secret, or lmore than 10 u should be able to do better.. i been trying to plug in if tries=10, <10 , >10 etc but that doesn't work..not sure where i would place it. can someone assist.
thanks!
Code:#include<stdio.h> #include<time.h> #include<stdlib.h> int main(void) { int theNumber; int tries,guess,yesno=1; srand (time(0)); do { theNumber=rand()% 1000+1; tries=0; printf("I have a number between 1 and 1000.""Can you guess my number? \n\n"); do { printf("Please type your first guess:"); scanf("%d",&guess); ++tries; if (guess > theNumber) printf("To high!! Try again.\n\n"); if (guess < theNumber) printf("To low!! Try again. \n\n"); } while (guess != theNumber); printf("Excellent! You guessed the number!\n"); printf("Would you like to play again?\n"); printf("Please type (1=yes, 2=no)?\n"); scanf("%d",&yesno); } while(yesno==1); return 0; }