Menu
Question Index
...


Write a program to copy the odd numbers into another array.

Input (Integer Array) Output (Integer Array)
{2, 3, 4, 6, 7, 1} {3, 7, 1}
{3, 9, 1, 16, 5, 10} {3, 9, 1, 5}

class CopyOddNumbersInArray

{    public static void main(String s[])
    {
        int[] input = {2, 6, 3, 8, 1};
        int[] output = copyOddNumbers(input);
        System.out.print("Odd Numbers in the array are : ");
        for(int i = 0; i < output.length; i++)
        {
            System.out.print(output[i] + ", ");
        }

    }


public static int[] copyOddNumbers(int[] input)
{
int[] output = null;
//Write code here to copy the odd numbers in input array and assign it to output
return output;
}
}

Doubts

Problems

Topic: Learn Arrays And Loops

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App