Apart from the heavy memory consumption problem stated by "death_o_clock" which need to be corrected,your program has other major errors.
1> picked[8] can carry flags only up to integer 7 and
for (i = 0; i < 9; i++)
picked[i] = 0;
will itself give error.Therefore picked[9] is the declaration you should make for your idea to work.
2> Other major flaw is in code
for (i = 0; i < 9; i++)
{
value = rand () % 9;
if (picked[value])
i--; // already picked. for-loop increments, so decrement here
else
{
array[i] = value;
picked[value] = 1; // hasn't been picked yet. Assign to array,
// flag as picked.
}
}
// display
for (i = 0; i < 9; i++)
printf("Values in the array are %d\n", array[i]);
getch();
return value;
You have taken so much time to generate 9 random numbers 0-8 ( rand() % 9 )such that if a number repeats then it is not considered and again a number is generated a random.
After all this effort you are just sending the random number which is generated at last back to main.
This is just as calling :
for(i=0;i<9;i++)
s=rand()%9;
in main itself.Ultimately you are just getting the random value generated on the ninth looping.