An array, numbers, of integers is filled with 100 random numbers whose values are greater than 10 and less than 255. You DO NOT have to write code to generate the random numbers. Write the code to count how many of the even numbers in the array are greater than 10 and less than 157 (inclusive).

Respuesta :

Answer:

int counter = 0;

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

if(myarr[i]%2==0){

if(myarr[i] > 10 && myarr[i]<157){

counter++;

}

}

}

cout<<counter;

Explanation:

The question is answered using c++ and it assumes that the array name is myarr

This line initializes counter to 0

int counter = 0;

This iterates through the array

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

This checks if current array element is even number

if(myarr[i]%2==0){

If the above condition is true; This checks if the array element is within the range of 10 and 157 (inclusive)

if(myarr[i] >= 10 && myarr[i]=<157){

If yes, the counter is increased by 1

counter++;

}

}

}

This prints the total counter number

cout<<counter;

ACCESS MORE