Page 186 - CA_Blue( J )_Class10
P. 186

B.  Fill in the blanks.

                  1.  To find all the even numbers from 2 to 20, the loop will execute for ………………… times.
                  2.  In for loop, i<=10 is known as ………………….
                  3.  i++ in while loop is known as ………………….
                  4.  To print the sum of 10 natural numbers using loop, System.out.print(sum) statements should be written ………………… the loop.
                  5.  If i = 1, then the loop while(i < 5) {i++} will execute ………………… times.

              C.  Answer the following questions:
                  1.  Write the programs in Java to display the following series.
                    a.  1 2 3 4 5 ….. 10                            b.  1 3 5 7 9 ….. 19
                    c.  0 3 8 15 …… 99                              d.  5 10 15 20 … 50

                    e.  1 2 3 , ...  10  ,                           f.   2 4 6  10  ,
                                                                         ,, ,...
                         ,
                           ,
                       3 6 9     30                                    4 6 8    12
                  2.  Write the Java programs to calculated the result of the following series:
                    a.  s=1+2+3+4+5…..+20                           b.  p=1*3*5*7*9
                    c.  s=1+11+111+1111+11111                       d.  p=2*4*8*16*32
                                                                                                      ... 10
                                                                                    ++
                                                                                                ++
                    e.  s=1+(1*2)+(1*2*3)+(1*2*3*4)+ (1*2*3*4*5)     f.  s= 1  +  1 + 2  +  12 3  + ... +  123 +
                                                                         1
                                                                            12
                                                                              *
                                                                                   12
                                                                                                ** ... * 10
                                                                                               123
                                                                                    ** 3
                                      9
                    g. p=  1  *  2  *  3 4  * ... *  10
                            3
                         2
                  3.  Write a program in Java to input two numbers and print the LCM of the numbers.
                  4.  Write a program to input a number and print the digits separated by comma (,) in reverse order.
                      Example: n=3456
                     Output: 6,5,4,3,
                  5.  Write a program in Java to input a number and print the sum of the even digits and product of the odd digits.
                      Example: n = 23785
                     Output: Sum of the even digits is: 10
                     Product of the odd digits is: 105
                  6.  Write a program to print the result of the following series where the unknown values are to be accepted by user.
                              3
                                  4
                        1
                           2
                                                                              2
                                                                                  2
                    a.  a  + a  + a  + a  + …… + a                 b.  s = x  + 2x  + 3x  + …. + nx 2
                                          n
                                                                          2
                          1
                             2
                    c.  p= 1  * 2 *3 ….n n                         d.  s=  1  +  1  +  1  + ... +  1
                                3
                                                                          2    4    6       10
                         1   1   1      1                              a   a   a      a
                    e.  s= !2  + !4  + !6  + ... + !10             f.   2 *  4 *  6 *...*  10
                         1
                                4
                                   5
                           2
                              3
                    g.  s=a -a +a -a +a …a n                       h.  p=(x+1)*(x+3)*(x+5)*….*(x+n)
                  7.  Write a program to input a number and print whether the number is a Niven number or not. A Niven number which is divisible
                    by the sum of the digits. Example: 111 because 1+1+1= 3, and 111 is divisible by 3.
                  8.  Write a program to input a number and check whether it is an Automorphic number or not. A number is Automorphic if the
                    square of the number ends in the same digits as the original number.
                     Example: 76 = 762 = 5776, so last 2 digits 76 is same as the original number.
                  9.  Write a program to input a number and print whether the number is Krishnamurthy number or not. A Krishnamurthy number is
                    a number whose sum of the factorial of digits is equal to the number itself.
                     Example: 145, 1! + 4! + 5! = 1 + (1x2x3x4) + (1x2x3x4x5) = 1 + 24 + 120 = 145.
                 10.  Write a program to input a number and print whether the number is a spy number or not. A spy number is a number whose sum
                    of the digits and product of the digits are equal. Example: 1124, sum: 1+1+2+4 = 8 and product: 1x1x2x4 = 8.
                 11.  Write a menu-driven program to accept a number and print the number as a perfect number or trimorphic number according to
                    the user’s choice.
                    a.  Perfect Number: A number that is equal to the sum of the proper divisors of the number. Example: 6 = 1+2+3 = 6
                    b.   Trimorphic Number: A Trimorphic number is a number whose square ends in the same digits as the original number. Example:
                       24 = 24 x 24 = 13824
                 12.  Write a menu-driven program to print the following series according to the user’s choice using the switch case statement.
                    a.  s=1 + 12 + 123  + 1234+ 12345.              b.  p=  1  *  2  *  3  *... * nth term
                                                                         1   4  9
                184184  Touchpad Computer Applications-X
   181   182   183   184   185   186   187   188   189   190   191