Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- //Tucker Honeycutt
- //Guessing Game
- //Due 10/24
- int main()
- {
- //Defining integers
- int randomnum, num;
- int attempts = 1;
- srand(time(NULL));
- randomnum = 1 + rand() % 99;
- //set initial instructions
- printf("Enter a number between 1 and 100\n\n");
- printf("Enter a zero when complete\n\n");
- //start do-while loop
- do
- {
- //input
- scanf("%i" ,&num);
- printf("Number %i = %i:", attempts , num);
- printf("The random number is %d.\n\n", randomnum);
- attempts = ++attempts;
- if(num == randomnum)
- {
- if (attempts == 1)
- {
- printf("Awesome Job!");
- }
- else if (attempts >= 2 && attempts <= 5)
- {
- printf("Great Job!");
- }
- else if (attempts >= 6 && attempts <= 9)
- {
- printf("Good Job!");
- }
- else if (attempts >= 10 && attempts <= 13)
- {
- printf("OK Job!");
- }
- else if (attempts > 13)
- {
- printf("You're too Slow!");
- }
- }
- if(num < randomnum)
- {
- printf("\n\nToo Low!\n\n");
- }
- if(num > randomnum)
- {
- printf("\n\nToo High!\n\n");
- }
- }while(num != 0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement