I have a problem. I need to display the even numbers only ofan array. How do I d
ID: 3613944 • Letter: I
Question
I have a problem. I need to display the even numbers only ofan array. How do I do that? Thanks. Display the elements in the "numbers" array that reside ateven indexes. The array is as follows: int numbers[] = {11, 8, -7, 22, 3, 17, 6, -25, 10, 5,-12, -9, 14, 20, -13}Thanks for all the help you guys provide. I have a problem. I need to display the even numbers only ofan array. How do I do that? Thanks. Display the elements in the "numbers" array that reside ateven indexes. The array is as follows: int numbers[] = {11, 8, -7, 22, 3, 17, 6, -25, 10, 5,-12, -9, 14, 20, -13}
Thanks for all the help you guys provide.
Explanation / Answer
please rate - thanks the indexes start at 0 so I took even indexes as 0,2,4... Also you say even numbers but you also say even indexes--I took itas the 2nd if wrong that can easily be fixed import java.util.*; public class untitled {public static void main(String[] args) {int numbers[] = {11, 8, -7, 22, 3, 17, 6, -25, 10, 5, -12, -9, 14,20, -13}; int i; for(i=0;iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.