C.Game for guessing number between 1-10(using Generating Random Values)

 


#include<stdio.h>

#include<time.h>

#include<stdlib.h>

int main()

{

    

  int number,guess,noguess=1;

  srand(time(0));   //

  number=rand()%10+1; //here it is used for generating random numbers

  

  do{

      printf("Enter No betwen 1-100\n");

      scanf("%d",&guess);

      if(guess>number)

      {

          printf("Enter Loweer number!!!\n");

      }

      else if(guess<number)

      {

          printf("Enter Heigher number!!!\n");

      }

      else {

          printf("You guessed it in %d attempts \n",noguess);

      }

      noguess++;

  }while(guess!=number);

  return 0;

  

}

Comments