English

Write a program for the following. Fill a double dimensional array of order 4 × 5. Print the even elements of the array.

Advertisements
Advertisements

Question

Write a program for the following.

Fill a double dimensional array of order 4 × 5. Print the even elements of the array.

Code Writing
Advertisements

Solution

importjava.util.*;
class Q1
{
   public void main()
   {
     int RC[ ][] = new int [4][5];
     int r = 0, c = 0;
     Scanner sc = new Scanner(System.in);
     for(r = 0; r<4; r++)
     {
         for(c = 0; c < 5; c++)
         {
            System.out.print("Enter value for cell number"+r+“"+c+" :: " );
             RC[r][c] = sc.nextInt();
         }
         System.out.println(" Printing the even elements of the array : ");
         for(r = 0; r<4; r++)
         {
           for(c = 0; c <5; c++)
           {
               if(RC[r][c]%2=0)
              {
                   System.out.print(" " + RC[r][c]);
              }
           }
         }
     }
   }
}
shaalaa.com
  Is there an error in this question or solution?
Chapter 9: Arrays - Double Dimension - Exercises [Page 221]

APPEARS IN

Rupa Pandit Computer Applications [English] Class 10 ICSE
Chapter 9 Arrays - Double Dimension
Exercises | Q 1. (i) | Page 221
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×