Page 235 - ComputerScience_Class_11
P. 235

break;
                       case 1:
                       x=x+4;
                       System.out.println("X=" x);
                       break;
                       case 2:
                       x=x+6;
                       System.out.println("X=" x);
                       break; }
                   Ans.  class Main {
                           public static void main(String[] args) {
                               int m = 0;
                               int x = 0;
                               if (m == 0) {
                                   x = x + 2;
                                   System.out.println("X=" + x);
                               } else if (m == 1) {
                                   x = x + 4;
                                   System.out.println("X=" + x);
                               }
                               if (m == 2) {
                                   x = x + 6;
                                   System.out.println("X=" + x);
                               }
                           }
                       }
                    3.  class Main {
                           public static void main(String[] args) {
                           int i=5;
                       while(i>=15)
                       {
                       System.out.println(i)
                       i=i-2;
                       }
                           }
                       }
                   Ans.  class Main {
                           public static void main(String[] args) {
                         int i = 5;
                       while (i <= 15) {
                       System.out.println(i);
                       i = i + 2;
                       }
                           }
                       }






                                                                                              Statements and Scope  233
   230   231   232   233   234   235   236   237   238   239   240