PRASHNIKAप्रश्निका
‹ Back to the paper

Choose the correct option.

What is the method single() performing?

Computer Science20221 markMCQ
  • (i)Sum of the positive odd elements
  • (ii)Product of the even elements
  • (iii)Product of the positive even elements
  • (iv)Sum of the positive even elements
Show the code
void single(int x[])
{
    int w = 1;
    for(int y = 0; y < x.length; y++)
    {
        if(x[y] % 2 == 0 && x[y] > 0)
            w = w * x[y];
    }
    System.out.print(w);
}

Answer

Answer

AI

Correct option: (iii)

Answer: (iii) Product of the positive even elements w is multiplied only by elements that are even and greater than 0.
Arrays, Strings

From ISC 2022 Computer Science - Specimen paper (Semester 1), Paper 1, question 29(b).