Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.18 KB | None | 0 0
  1. int main()
  2. {
  3.    int randomnum, num;
  4.    int attempts = 1;
  5.    randomnum = 1 + rand() % 99;
  6.  
  7.    printf("Enter a number between 1 and 100\n\n");
  8.    printf("Enter a zero when complete\n\n");
  9.  
  10.  
  11.    do
  12.    {
  13.        scanf("%i" ,&num);
  14.        printf("Number %i = %i:", attempts , num);
  15.        srand(time(NULL));
  16.        printf("The random number is %d.\n\n", randomnum);
  17.  
  18.  
  19.        attempts = ++attempts;
  20.  
  21.  
  22.        if(num == randomnum)
  23.        {
  24.            printf("\n\nYou did it!\n\n");
  25.  
  26.             if (attempts == 1)
  27.             {
  28.                 printf("Awesome Job!");
  29.             }
  30.                 else if (attempts <= 2 && <= 5)
  31.             {
  32.                 printf("Great Job!");
  33.             }
  34.             else if (attempts <= 6 && <= 9)
  35.             {
  36.                 printf("Good Job!");
  37.             }
  38.             else if (attempts <= 10 && <= 13)
  39.             {
  40.                 printf("OK Job!");
  41.             }
  42.                 else (attempts > 13)
  43.             {
  44.                 printf("You're too Slow!");
  45.             }
  46.        }
  47.        else if(num < randomnum)
  48.        {
  49.            printf("\n\nToo Low!\n\n");
  50.        }
  51.        else
  52.        {
  53.            printf("\n\nToo High!\n\n");
  54.        }
  55.    }while(num != 0);
  56.  
  57.     return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement