Page 386 - CA_Blue( J )_Class10
P. 386

33              break;
                34              case 2:

                35              System.out.print("The odd positive numbers are: ");
                36              for (i=0; i<5; i++)

                37              {
                38                  if(ar[i]%2==1 && ar[i]>0)

                39                  { System.out.print(ar[i]+ " : " );    }
                40              }

                41              break;
                42              default: System.out.println("Wrong Choice");

                43          }
                44      }

                45  }

              You will get the following output:
              Enter any five numbers(three digit) : 153
              Enter any five numbers(three digit) : 370
              Enter any five numbers(three digit) : 371
              Enter any five numbers(three digit) : 103
              Enter any five numbers(three digit) : 102
              Enter 1 for Armstrong Numbers :
              Enter 2 for odd positive numbers :
              Enter your choice 1
              The Armstrong numbers are : 153 : 370 : 371 :
                              To input numbers in an array of size 3 x 4 and print the square of the numbers in matrix
                Program 6
                              format.

                 1  import java.util.*;

                 2  class array_double_matrix
                 3  {   public static void main()
                 4      {   Scanner sc= new Scanner(System.in);

                 5          int ar[][]=new int[3][4];

                 6          int i,j;
                 7          for (i=0; i<3; i++)

                 8          {   for(j=0;j<4;j++)
                 9              {   System.out.print("Enter a number : ");

                10                  ar[i][j] =sc.nextInt();
                11              }



                384384  Touchpad Computer Applications-X
   381   382   383   384   385   386   387   388   389   390   391