garbage numbers problem

hi guys , i have a problem with my code which when i print my random numbers , at the end it prints garbage numbers of negative integers. the random numbers are fine but the last line is not. i know it could be the function call but when i use fillRandom(arr,range,min); it says range and min are identifer undefined. Right now im using fillRandom(arr) which includes the code problem. please help and thank. Also, if it is a simply fix, can you give me the straight answer.
void fillRandom(int * , int range = 100, int min = 0);
//prototype
int main()
{
int arr[7];
case 2:
cout << "Here is your input:" << endl;
fillRandom(arr,range,min);
display(num);
cout << endl;
cout << " Would you like to use bubble sort 1) or selection sort 2) " << endl;
cin >> choice;
break;
}

void fillRandom(int *arr, int range, int min)
{

for (int i = 0; i < 7; i++)
{
arr[i] = rand() % range + min;
cout << arr[i] <<endl;
}
}

void display(int num[])
{
for (int count = 0; count < NUMBERS; count++)
{
cout << num[count] << " ";
// prints out the array
}
cout << endl;
srry code was long, text me if need it
use this random function

#include <cstdlib>
#includt <ctime>

int main()
{
srand(time(NULL));
}

1
2
cout << rand()%100; //prints a number btw 0-99
cout << rand()%101; // prints 0-100 
Last edited on
In void fillRandom(int *arr, int range, int min) try changing the * to a &, I believe you want to be passing it by reference. Your full code would be helpful to find the exact problem.

Please also use code tags. They are the <> symbol on the right of the text box. It makes code easier to read.
Thank you guys , but I found the problem which I Changed function call to (num,range, min) to be simple. Sorry wasting your time
Topic archived. No new replies allowed.