the following program I wrote to print the random number between 0 and 100. it is returning me the sane number 20 times. I want it to print different numbers. Can anyone help me out?
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int RANDOM(int a, int b)
{
srand(time(0));
if (b<a)
swap(a, b);
int y=a+(rand()%(b-a));
return y;
}
int main()
{
int start, end, num;
cout<<"Enter the start of the Range: ";
cin>>start;
cout<<"Enter the ending point of Range: ";
cin>>end;
for(int i=1; i<=20; i++)
{
num = RANDOM(start,end);
cout<<num<<endl;
}
return 0;
}