हिंदी

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

Advertisements
Advertisements

प्रश्न

Write a program for the following.

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

कोड लेखन
Advertisements

उत्तर

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
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 9: Arrays - Double Dimension - Exercises [पृष्ठ २२१]

APPEARS IN

रुपा पंडित Computer Applications [English] Class 10 ICSE
अध्याय 9 Arrays - Double Dimension
Exercises | Q 1. (i) | पृष्ठ २२१
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×