diff --git a/random_game.c b/random_game.c new file mode 100644 index 0000000..a0dfe39 --- /dev/null +++ b/random_game.c @@ -0,0 +1,38 @@ +#include +#include +#include + + +int main(){ + + int n , attempts = 1; + char str[20]; + srand(time(NULL)); + + int num = rand(); + + int rand_num = num % 100 + 1; + printf("Random No. is : %d",rand_num); + + printf("\nEnter Your Name : "); + scanf("%s",&str); + do{ + + printf("\nEnter the no : "); + scanf("%d",&n); + + if(nrand_num){ + printf("\ntry lower no."); + } + else + { + printf("\nCongratulations !!! %s, You got this in %d attempts",str,attempts); + } + + attempts++; + + }while(n != rand_num); +} \ No newline at end of file