Advertisement
Guest User

Untitled

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