Finding smallest number in a random array of numbers.

I am writting a program that needs to find the smallest number from a chosen array of random numbers from 1-10000. Here is some pseudo code that was given in class.

double smallestNum = Max +1

for(int i = 0; i< arraysize ; ++ i)
if (array[i]<smallestNum)
smallestNum=array[i]
return smallestNum

So, this makes sense to me how the code works but I am having trouble applying the concept to my code and I still haven't fully figured out how to generate the random number that I need for the specified range of 1-10000. The program is also using user defined functions as well so I confused on how to reference the the values entered for the previous integers to the sub function. >.<

Code I have so far:

#include <stdio.h>
#include <stdlib.h>

double mean(double ar[]);
double smallest(double ar[]);
double largest(double ar[]);
int main(void)
{
int seed;
double array[1000];
int arrIndex=0;
int max;
char chh;

{
//Prompts user to enter the value for integer "max".

max=0;
printf("\nEnter the upper bound: ");

fflush(stdin);
scanf("%d",&max);

//If statement checking that the value for max is greater than 10.
if (max <= 10)
{
printf("Upper bound should be %d greater than 10.",max);
fflush(stdin);
}

//If test passes, prompt user for the value of seed.
else{
printf("Enter the seed for random generation: ");
scanf("%d",seed);
}
//Incomplete
srand(seed);
for(arrIndex=1; arrIndex<=10000; ++arrIndex)
{

}
fflush(stdin);
scanf("%c", &chh);
return 0;
}}
//Function to find smallest number in array.
double smallest(double ar[])
{
int smallestNum=max + 1;
int i;

for (int i=0; i<arrIndex; ++ i)
{
smallest=array[i];
return smallestNum;
}

I will also have to find largest but I know it will be similar to the smallestNum function so no problems there, I just think my code organization is just crazy...

Thanks everyone.

PS: Student at SJSU, first time coding with C+, or coding period. lol.
[2327 byte] By [whitebluesc2] at [2007-11-20 11:18:21]
# 1 Re: Finding smallest number in a random array of numbers.
Two things:

used rand() to generate the random numbers:

for(arrIndex=0; arrIndex < 1000; ++arrIndex) // ypu wrote 10000 not 1000
{
array[arrIndex] = 1 + rand() % 10000;
}

in your smallest function, make the smallestNum a double, not int

double smallestNum=max + 1;

you should use the same type as the array's elements
cilu at 2007-11-10 22:26:01 >