Respuesta :

Answer:

It should be initialized to 0

Explanation:

Take for instance, the following code segment;

//Initializes numNegatives to 0

int numNegatives = 0;

// Iterate through the array

for (int i =0; i<length;i++){

//Check for negative array element

if(userVals[i]<0){

//Increment numNegatives

numNegatives++;

}

}

Initializing numNegatives to 0 allows the counter to start from 0, so that all once the program encounters a negative element, numNegatives is incremented

Following are the solution to the  given question:

  • NumNegatives must be set to 0 because if there are no negative numbers in the array, we must return 0.
  • Also, since we have not scanned the array, the number of negative numbers found is zero.

                 OR

  • These variables we are using for counting are often referred to it as count variables, and they've been set to zero.
  • Whenever a negative number is encountered, the value is incremented by one, and the smart objects inside the count variable are finally returned as that of the number of times the negative result was encountered.

Therefore, the final answer is "0".

Learn more:

brainly.com/question/15140303

Ver imagen codiepienagoya