Quoted By: >>44786191 >>44786191,1
What to help me with my homework /g/?
Why the fuck does why does the last arr2 printf keep giving a huge negative number?
Why the fuck does why does the last arr2 printf keep giving a huge negative number?
int main()
{
int arr[100];
int arr2[9];
int size;
scanf("%d", &size);
initialize_array(arr, size);
printf("\n%d", count_numbers(arr, size, 4));
arr2[4]=count_numbers(arr, size, 4);
printf("\n%d", arr2[4]);
return 0;
}
void initialize_array(int arr[], int size)
{
int i;
srand(time(NULL));
for(i=0; i<size; i++)
{
arr[i]=rand()%10;
}
}
int count_numbers(int arr[], int size, int num)
{
int i, count;
for(i=0; i<size; i++)
{
if(arr[i]==num)
{
count++;
}
}
return count;
}