How do I make my addRandomNumbers()
function add different numbers to the array ? Right now it is just adding the same number.
I dont know what i did wrong, I had it outside of the for loop originally and it still generated the same number.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define clear system("cls")
#define pause system("pause")
#define SIZE 5000
#define LB 1 //this is the lower bound
#define UB 500 //this is the upper bound
//Lets Prototype
void addRandomNumbers(int n[]);
void bubbleSort(int n[]);
void displayRandomNumbers(int n[],int c[]);
int main(){
int numbers[SIZE]={0}, counter[SIZE]={0};
addRandomNumbers(numbers);
bubbleSort(numbers);
displayRandomNumbers(numbers,counter);
}
void addRandomNumbers(int n[]){
int i;
for (i=0; i < SIZE; i++){
srand((unsigned)time(NULL));//seed the random number function
n[i] = LB + rand() % (UB - LB + 1 );
}
}
void bubbleSort(int n[]){
int i,temp=0;
for(i=0;i<SIZE-1;i++){
temp=n[i];
n[0]=n[1];
n[i+1]=temp;
}
}
void displayRandomNumbers(int n[], int c[]){
int i;
for(i=0;i<LB;i++)
printf("It is %i\n",n[i]);
pause;
}