Help with code
trying to create a hi-lo guessing game , random function is not giving correct result #include<iostream> #include<ctime> #include<cstdlib> int getnumber() { int num; while(1) { std::cin>>num; if(std::cin.fail()) { std::cin.clear(); std::cin.ignore(32767,'\n'); } else return num; } } int ran_num() { int max(10),min(1); std::srand(std::time(nullptr)); static const double fraction = 1.0 / (RAND_MAX + 1.0); return min+(static_cast<int>((fraction*std::rand())*(max-min+1))); } bool playagain(char choice) { if(choice=='y'||choice=='Y') return 1; return 0; } void ischeck(int guessnum) { int usernum=ran_num(); std::cout<<usernum<<"\n"; if(usernum<guessnum) { std::cout<<"Guess is high"<<"\n"; } else if(usernum>guessnum) { std::cout<<"Guess is low"<<"\n"; } else if (usernum==guessnum) std::cout<<"Congrats you guessed correct num"<<"\n"; } int main() { for(int i=0;i<2;i++) { int n1=getnumber(); ischeck(n1); } }