Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <time.h>
- int main()
- {
- int guess;
- int attempts;
- srand(time(NULL));
- int special_number = rand() % (10000 +1 - 0) + 0;
- for(attempts=1; guess!=special_number; attempts++){
- printf("Please guess the random number\nBetween 0 and 10000! ");
- scanf(" %d", &guess);
- if(guess==special_number){
- printf("Congratulations! The number was %d\nIt took you %d attempts.\n", special_number, attempts);
- }else if(guess<special_number){
- printf("Too low! Guess higher!\n");
- }else{
- printf("Too high! Guess lower!\n");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement