Page 174 - CA_Blue( J )_Class10
P. 174

}
                     Value of a is ………………… after the execution of the loop.
                  2.  The ………………… and ………………… loops are entry controlled loop.
                  3.  In a loop, if the increment or decrement changes by 1 only for each iteration, then it is called ………………… loop.
                  4.  ………………… transfers the program control to another part of the program which basically depends on the given condition.
                  5.  Since the do-while loop executes at least once, we can term it as an ………………… loop.
                  6.  There are ………………… different parts in a loop.
                  7.  Consider the following code:
                    int n=123, r, s = 0;
                    while(n > 0)
                    {
                          r = n % 10;
                          s = s + r;
                          n = n / 10;
                    }
                     The final value of s is ………………….
                  8.  If a loop does not have any statement in the body then it is a ………………… loop.
                  9.  The ………………… statement takes the control back to the caller module from the method.
                 10.  The do-while loop will execute ………………… even if the test condition is false.

                Answers
                   1.  -10             2.  for, while        3.  continuous    4.  Jump statement   5.  Exit Controlled
                   6.  4               7.  6                 8.  Null          9.  return          10.  at least once


              C.  Answer the following questions:
                  1.  How many times 'India' will be printed?
                    class question1 {
                          public static void main( )
                          {
                               for(int i = 0; i<5; i=i+2)
                               {
                                 System.out.println("India");
                               }
                          }
                    }
                Ans.  3 times
                  2.  What is the output of the below Java program?
                    int i=1;
                    while(i<4)
                    {
                        System.out.print((i+2) + " ");
                        i=i+2;
                    }
                Ans.  3 5
                  3.  Write the output when the program is executed. Also, how many times the loop will execute?
                    int i=0;
                    while(true)
                    {
                        if(i > 4)
                            break;
                        System.out.print(i + ",");
                        i++;
                    }


                172172  Touchpad Computer Applications-X
   169   170   171   172   173   174   175   176   177   178   179