Given the following code, what logic would you need to include to print all even values stored within the array:

int[] myArray = {1,2,38,4,54,6,7,8,9,10};

for (int i = 0; i < myArray.length; i++) {
//your code goes here
}
NOTE: Your response should be just the missing logic--not the entire problem set.

Answers

Answer 1

The missing logic whigh would allow all the even numbers stored within the array to be printed is if(myArray[i]%2 == 0)

Even numbers are divisible by 2, and hence, will leave no remainder when divided by 2.

Using the modulo operator, each iterated value in the array should be checked if it has a remainder of 0, when divided by 2.

Hence, if the remainder is 0, then the value is even and the value should be printed.

Learn more : https://brainly.com/question/17330574


Related Questions

three types of query​

Answers

It is commonly accepted that there are three different types of search queries:

Navigational search queries.

Informational search queries.

Transactional search queries.

Other Questions
Dina and masha started out on a 12 mi bike path at the same time. when dina reached the end of the 12 mi, masha still had 4 mi left to bike. if dina's biking speed is 10 mph, find masha's biking speed. HELP NOWWW PLEASE HELP ME I'LL GIVE BRAINLIST!!!!!!!! Q: Explain how the four-game mechanics mentioned in the unit (reward, risk/loss, levels, and feedback) could work together to create an interesting sports video game. What distance does a police car travel if it is going 3.0 m/s for 20 seconds How is soil polluted?Explain. -x+3y=0x+3y=12System of linear equation by elimination how do you separate the following mixture? Name only the process involved .1.Sand and salt pas n'etudiez vous d'accord demain where is here? Joyce Carol About the father. A. Val Pro ProB. Leu His Ser C. Pro Val Pro D. Val Leu Pro Vesta is a minor planet (asteroid) that takes 3.63 years to orbit the Sun. Calculate the average sun -Vesta distance Andrew shovels snow for 4 %2 hours and makes$27. How much did he make per hour?And how much does he earn in 8 hours? tony purchases a pair of jeans for 45.49 before tax the jeans were originally priced at 69.99 what was the percent discount a 35% B 20% C 65% and D 80% pls help the book is think up 1.What is a theme of the story?aA. It is important to celebrate holidays the same way each year.B. Hard times can be easier with help from friends.C. Being away from home is hard for everyone.D. Be careful not to lose important things. What is the true nature of science? I need it for tomorrow.. 7x+14y3y+12x+32y+54x+2x+8y A water sprinkler covers the area shown in the figure.It moves through the covered area at a rate of about 5 per second.What is the measure of the are covered by the sprinkler?If the sprinkler starts at the far left position,how long will it take for the sprinkler to reachthe far right position? Which of the following describes how to write the decimal number six hundred twenty-seven thousandths? identify the non finite verbs. (1) hunting is prohibited. (2) I need to go to sleep. (3) I saw him running. (4) flying makes me nervous. (5) i find speaking stressful. (6) this is an interesting book. (7) I love the noise of falling rain. (8) he was hopeless at writing letters (9) we have to submit our assingment by Friday. (10) I love camping in the woods. plzz faltu javaab mat dena mera assignment ke liye h plzz 5 ) Which village has been declared the cleanest village in India ?