Priyanshu_Gupta

Guess the number

Sep 13th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.72 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<stdlib.h>
  4. #include<time.h>
  5. int main()
  6. {
  7.     int number,guess ,attemp=1;
  8.     srand(time(0)); //In how many second time update...
  9.     number=rand()%100+1;  // Number Geneate Between 1 to 100
  10.     // printf("Number is %d",number);
  11.     do
  12.     {
  13.         printf("\nEnter a Number :\n");
  14.         scanf("%d",&guess);
  15.         if(guess<number)
  16.         {
  17.             printf("Lower Number");
  18.         }
  19.         else if(guess>number)
  20.         {
  21.             printf("Higher Number");
  22.         }
  23.         else
  24.         {
  25.             printf("You Entered correct Number in : %d Attempts",attemp);
  26.         }
  27.         attemp++;
  28.     } while (guess!=number);
  29.    
  30.     getch();
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment