The program is a bit tedious because the answer is hardcoded
The program is a bit tedious because the answer is hard-coded into the program. Make a version where the user can play repeatedly (without stopping and restarting the program) and each game has a new set of digits. You can get four random digits by calling the random number generator randint(10) from std lib facilitie.h four times. You will note that if you run that program repeatedly, it will pick the same sequence of four digits each time you start the program. To avoid that, ask the user to enter a number (any number) and call seed randint(n), also from std_lib_facilities.h, where n is the number the user entered before calling randint(10). Such an n is called a seed, and different seeds give different sequences of random numbers.
Solution
#include<bits/stdc++.h>
#include \"std_lib_facilities.h\"
using namespace std;
int main(int argc, char const *argv[])
{
cout<<\"Enter any number \ \";
int n;
cin>>n;
seed_randint(n);
int a=randint()%10;
int b=randint()%10;
int c=randint()%10;
int d=randint()%10;
cout<<\"random numbers are \"<<a<<\" \"<<b<<\" \"<<c<<\" \"<<d<<endl;
return 0;
}
=======================================================
Output:
akshay@akshay-Inspiron-3537:~/s$ g++ randoin.cpp
akshay@akshay-Inspiron-3537:~/s$ ./a.out
Enter any number
3
random numbers are 6 5 8 0
