SHARE
TWEET

q2

pedrolemoz Sep 16th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # include <stdio.h>
  2. # include <time.h>
  3.  
  4. int select(int);
  5.  
  6. int main(){
  7.     int number, range, guess;
  8.    
  9.     printf("Type a number to be the range: ");
  10.     scanf("%d", &number);
  11.    
  12.     while(guess != number){
  13.         printf("\nGuess the number between 1 and %d: ", number);
  14.         scanf("%d", &guess);
  15.        
  16.         number = select(number);
  17.        
  18.         printf("\n%d\n", number);
  19.     }
  20.     printf("\nYou guess was right!\n");
  21.     printf("\nPress any key to exit...\n");
  22.     getch();
  23.     return 0;
  24. }
  25.  
  26. int select(range){
  27.     srand(time(NULL));
  28.    
  29.     return 1 + rand() % range;
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top