0

How to generate truly random numbers in given range in c++ sololearn

/*This function generate truly random numbers from given starting point to end point. Try it -- */ #include <iostream> #include <cstdlib> #include <ctime> using namespace std; void RandomNumbers(int y, int z); int main () { int start_point; int end_point; cin>> start_point; cin>> end_point; RandomNumbers(start_point, end_point); } void RandomNumbers(int y, int z) { srand(time(0)); for (int x=0; x<=10; x++) { int a = (rand() % z); if (a < y) { cout<< a+y <<endl; } else { cout<< a <<endl; } } }

12th Aug 2022, 11:17 AM
Ankit Sahu
Ankit Sahu - avatar
1 Antwort
+ 6
Ankit Sahu , what is your question? you posted it repeatedly.
12th Aug 2022, 11:30 AM
Lothar
Lothar - avatar