Guess the number

 #include <stdio.h>

#include <stdlib.h>

#include <time.h>


int main(){

    int mynum ,usernum;

    srand(time(NULL));

    mynum = rand()%10;


    printf("I have a number in my mind (0-10) ; can you guess it !\n");

    while(1){

        printf(" Enter your guess ");

        scanf("%d",&usernum);



    if(usernum == mynum){

        printf("you got it!\n");

        break;

    }else if (mynum < usernum){

    printf("you enter %d is greater than my num try again" , usernum );

    }else {printf("you enter %d is less than my number try again" , usernum);

    }

    }




 return 0;

}

Comments

Popular posts from this blog

Factors : using C

Cross shaped pattern

Factorial ! calculation