I'm not sure what range of numbers you were trying to get, but something like this should work -
Code:
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
int randomNums[5] = {-1,-1,-1,-1,-1};
int index = 0;
int temp = 0;
char found = 'n';
int i = 0;
srand(time(NULL) );
while (index < 5)
{
found = 'n';
temp = 1 + rand()%10;
for(i=0;i<index;i++)
{
if (randomNums[i]==temp)
{
found ='y';
break;
}
}
if(found=='n')
randomNums[index++]=temp;
}
for(i=0;i<5;i++)
cout<< randomNums[i]<< endl;
return 0;
}