Advertisement
Guest User

Untitled

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