#include <stdio.h> #include <stdlib.h> #include <time.h> int main() { srand(time(NULL)); int randNum = rand()%100,userNum=0,correct=0; while(correct==0) { printf("Guess the hidden number between 0 and 99:"); scanf("%d",&userNum); if(userNum==randNum) { printf("Congratulations! You guessed correctly!"); correct=1; } else if(userNum<randNum) { printf("You guessed too low\n"); printf("Better luck next time\n"); } else { printf("You guessed too high\n"); printf("Better luck next time\n"); } } }
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more