Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.16 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(num < randomnum)
  27.        {
  28.            printf("\n\nToo Low!\n\n");
  29.        }
  30.        if(num > randomnum)
  31.        {
  32.            printf("\n\nToo High!\n\n");
  33.        }
  34.  
  35.  
  36.        if (attempts == 1)
  37.        {
  38.            printf("Awesome Job!");
  39.        }
  40.        else if (attempts <= 2 && <= 5)
  41.        {
  42.            printf("Great Job!");
  43.        }
  44.        else if (attempts <= 6 && <= 9)
  45.        {
  46.            printf("Good Job!");
  47.        }
  48.        else if (attempts <= 10 && <= 13)
  49.        {
  50.            printf("OK Job!");
  51.        }
  52.        else (attempts > 13)
  53.        {
  54.            printf("You're too Slow!");
  55.        }
  56.  
  57.  
  58.    }while(num != 0);
  59.  
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement