- 4
Array
int [] myArray = new int {30,29,28,27,26,5,4,3,2,1}; // new array here; // logic for writing to new arrays in this loop. for(int i =0; i<_; i++){ } // output in this loop. for( Create three arrays. Fill one array with numbers, enter even numbers into the second, and add odd numbers from the first array to the third.
5 Answers
+ 1
Martin Taylor Can you pls check my answer?
+ 1
Martin Taylor Can you tell me what you are doing in 23rd line?
+ 1
Great thanks Martin Taylor
0
public class Program
{
public static void main(String[] args) {
// Array
int [] myArray = {30,29,28,27,26,5,4,3,2,1};
// new array here;
// logic for writing to new arrays in this loop.
System.out.println ("Only numbers ->\n");
for(int i =0; i<myArray.length; i++){
System.out.print (myArray[i]+",");
}
System.out.println("\nEven numbers->\n");
// output in this loop.
for(int i=0;i<myArray.length;i++)
{
if(myArray[i]%2==0)
System.out.print (myArray[i]+",");
}
/*
Create three arrays. Fill one array with numbers, enter even numbers into the second, and add odd numbers from the first array to the third.*/
}
}
0
Now you do it for odd numbers by yourself