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

With reference to the program code given below, answer the following question: void dimen(int…

Computer Science20222 marksMCQ
With reference to the program code given below, answer the following question:
void dimen(int n[][])
{
    int p = 0;
    for (int i = 0; i < n.length; i++)
        for(int j = 0; j < n[0].length; j++)
        {
            if(i == 0 || i == n.length - 1 || j == 0 || j == n[0].length - 1)
                p = p + n[i][j];
        }
    System.out.print(p);
}
What will be the output of the method dimen() when the value of `n[][] = {{2,3,7},{1,5,9},{10,-3,8}}`?
  • (i)42
  • (ii)33
  • (iii)5
  • (iv)37

Answer

No answer yet.

Arrays, Strings

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