Small program of the Random Function rand ():
#include <iostream>
#include <time.h>
#include <fstream>
#include <windows.h>
using namespace Std;
unsigned t[300],temp;
void Creat_rand ()//functions that produce random numbers
{
Long I=1;
cout<< "The random number generated for you is as follows:" <<endl;
Srand (Time (0)); Use this function to set the seed value so that the random number generated each time is different
for (i=1;i<21;)
{
Temp= (rand ()%10000+1000);
if (temp>999 && temp<=9999)
{
T[i]=temp;
cout<< "<<i<<" <<t[i]<< "";
if (i%5==0)
cout<<endl;
i++;
}
}
}
void Search_number (unsigned t[],int n)/Lookup function
{
cout<<endl;
DeleteFile ("Randnumber.txt");
System ("pause");
cout<< "Two digits equal to random number:" <<endl;
Ofstream output ("Randnumber.txt", ios::out);
int cand1,cand2;
for (int i=1;i<n;i++)
{
cand1=t[i]%10;
CAND2=T[I]%100/10;
if (CAND1==CAND2)
{
cout<<t[i]<< "";
output<<t[i]<< "";
}
}
Output.close ();
}
void main ()//main function
{
Creat_rand ();
Search_number (t,20);
}