Top 10 output questions from Arrays Class 10 ICSE

 THE FOLLOWING OUTPUT QUESTIONS FROM ARRAYS PROVIDES A GOOD PRACTICE TO STUDENTS FOR ARRAYS.

1) int a[] = {2,4,6,14};

        int b[] = {6,3,7,8};

        a = b;

        System.out.print("\n a[2] = "+a[2]);

        System.out.print("\n b[2] = "+b[2]);

OUTPUT:

a[2] = 7

b[2] =7

2) int arr[] = {2,5,6,10,18,17,14,20,39};

        System.out.println(arr.length);

OUTPUT:

9

3) int array[] = {2,5,6,10,18,17,14,20,39};

        System.out.println(array[3+4]);

        System.out.println(array[1+7]);

        System.out.println(array[6-4]);

OUTPUT:

20

39

6

4) int array[] = {2,5,6,10,18,17,14,20,39};

        System.out.println(array[3]*4);

        System.out.println(array[7]*5);

        System.out.println(array[6+1]*2);

OUTPUT:

40

100

40

5)  public  void SHOW()

    {

        int x[] = {2,7,9,14};

        int y = x.length; int pos = 0;

        for(int i = 0; i<y;i++)

        {

            pos = x[i] + x[3-i];

            System.out.println(pos);

    }

}

OUTPUT:

16

16

16

16

6) int arr[] = {2,3,4,5};

        for(int i = 0; i< arr.length; i++)

        {

            for(int n = 0 ; n<= i; n++)

            {

                

            System.out.print(arr[n] + "");

        }

        System.out.println("\n");

    }

OUTPUT:

2

23

234

2345

7) int z[] = {46,48,59,82,64,105};

        System.out.print(z[4] + "," + z[3]*4);

 OUTPUT:

64,328

8) int num = 46785, n = 0;

        int ar[] = new int[5];

        while(num > 0)

        {

            ar[n++] = num % 10;

            num/= 10;

            System.out.println(ar[n-1]);

}

OUTPUT:

8

7

6

4

9) int ar[] = {4,6,8,12,18};

        int s[] = {ar[2] + ar[4]};

        int p[] = {ar[1+3] + ar[2]};

        System.out.println(s);

        System.out.println(p);

OUTPUT:

[I@leeb5d

[I@4757c

10) int n[] = { 1,2,5,6,19,22,37,4,10,8};

        double a = Math.pow(n[3],n[7]);

        double b = Math.sqrt(n[3] +n[8]);

        System.out.println(a);

        System.out.println(b);

OUTPUT:

1296.0

4.0


The above program CODE is compiled and is without any error.

Hope you guys found it helpful.

Please share it with your friends and comment down in the comment section below.

Follow https://askrisfor.blogspot.com/ for more such updates.

Visit us again.

Thank you!!

Comments

Popular Posts