public class MyClass {
public static void main(String args[]) {
// declaring varaibles
int n = 20, evenI = 0, oddI = 0;
int[] even = new int[n/2];
int[] odd = new int[n/2];
// looping from 1 to n
for(int i=1; i<= n; i++)
{
if(i % 2 == 0) // even numbers
{
even[evenI] = i;
evenI++;
}
else // odd numbers
{
odd[oddI] = i;
oddI++;
}
}
}
}
Please comment if you have doubts. Up vote. Happy Learning!
Get Answers For Free
Most questions answered within 1 hours.