Advertisement
Guest User

C Random Numbers Game

a guest
Oct 27th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.56 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. int main(void)
  5. {
  6.  
  7. int yourNumber;
  8. int count = 0;
  9.  
  10. srand(time(NULL));
  11. int r = (random() % 20) + 1;
  12.  
  13. int subsc = abs(yourNumber - r); // farkı buldum.
  14.  
  15. while(yourNumber != r){
  16.  
  17. printf("Sayini gir : ");
  18. scanf("%d",&yourNumber);
  19.  
  20. if(subsc == 4) // fark 4 ise ... desin
  21.         printf("Çok yaklaştın...");
  22.  
  23. count = count + 1;
  24.  
  25. if(yourNumber == r)
  26.     printf("%d kerede bulundu.\n",count);
  27.  
  28. printf("%d\n",r); // bulamiyorum diye sayinin kaç olduğunada bakayım dedim
  29. }
  30.  
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement