12.Random number Game

 #include <stdio.h>

#include <stdlib.h>
#include<time.h>

int main()
{
    int num, guess, guesses = 1;
    srand((0));
    num = rand()%100+1;
    // printf("The random number is :%d",num);

    do
    {
        printf("\nGuess the random number :");
        scanf("%d", &guess);
        if (guess > num)
            printf("\nLower number Please!");
        else if (guess < num)
            printf("\nGreater number Please!");
        else
        {
            printf("You take %d times to guess the number...", guesses);
        }
            guesses++;
    } while (guess != num);
   

    return 0;
}

Comments