0
Find out odd and even interger in an array
Sorry. i have added the count of oddarray && evenarray but it shows =9; can you help me by changing my program https://code.sololearn.com/cYQo1W9g7Dr9/?ref=app
10 Respuestas
+ 2
This is just to show the output and the code can be improved like ~ swim ~ mentioned.
https://code.sololearn.com/c9CT5Egl3Cfx/?ref=app
+ 1
Please tag Java arrays 👍
0
How to assign value in LHS... because I am new to java...
0
Yep...But still not getting desired ouput
package com.codewithjayaraj;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int j=0;
int k =0;
int[] dataArray = {1,2,56,86,60,6,7,8,9};
int[] oddarray =new int[9];
int[] evenarray= new int[9];
System.out.println("The data array"+dataArray);
for(int i =0; i<dataArray.length;i++){
if (dataArray[i] %2==0) {
oddarray[j]= dataArray[i];
oddarray[j]++;
}
else
evenarray[k] = dataArray[i];
evenarray[k]++;
}
System.out.println("The odd values are" +Arrays.toString(evenarray));
System.out.println("The even values are " + Arrays.toString(oddarray));
}
}
0
help me out to remove Zero in my output...Thanks a lot