Page 302 - IT-802_class_12
P. 302

17.   Consider the table ITEM with the fields – ITEM_NO, ITEM_NAME, ITEM_PRICE, ITEM_QUANTITY. Write a query to
             display the names of items in alphabetical order.
                       +---------------+-------------+------+-----+---------+-------+
                       | Field         | Type        | Null | Key | Default | Extra |
                       +---------------+-------------+------+-----+---------+-------+
                       | iTEm_NO       | int         | yES  |     | NULL    |       |
                       | iTEm_NAmE     | varchar(20) | yES  |     | NULL    |       |
                       | iTEm_pRiCE    | int         | yES  |     | NULL    |       |
                       | iTEm_QUANTiTy | int         | yES  |     | NULL    |       |
                       +---------------+-------------+------+-----+---------+-------+

         Ans. SELECT iTEm_NAmE FROm iTEm ORDER By iTEm_NAmE ASC;
          18.  Modify the table and add a column ITEM_COMPANY with the name and data type as VARCHAR(20).

         Ans. ALTER TABLE iTEm ADD iTEm_COmpANy VARCHAR(20);
          19.  In the table of Ques 17 and 18, write a query to display the names of all the companies without repetition.

         Ans. SELECT DiSTiNCT iTEm_COmpANy FROm iTEm;
          20.   In the table of ques 17, write a query to display no, name and quantity of the items whose quantity is less than 100.

         Ans. SELECT iTEm_NO, iTEm_NAmE, iTEm_QUANTiTy FROm iTEm WHERE iTEm_QUANTiTy < 100;
          21.  Write the output of the following program.

             import java.util.Scanner;
             class Square_sum
             {
                 public static void main(String args[])
                 {
                     Scanner sc = new Scanner(System.in);
                     System.out.print("Enter the value of n: ");
                     int n = sc.nextint();
                     double sq_sum = 0;
                     for (int i = 1; i <= n; i++)
                     {
                         sq_sum = sq_sum + math.pow(i, 2);
                     }

                     System.out.print(“Sum of the series is = " + sq_sum);
                 }
             }
         Ans. Enter the value of n: 5
             Sum of the series is = 55.0

          22.  Write the output of the following program.
             class Triangle_pattern
              {
                public static void main(String args[])
                {
                    for (int i = 1; i <= 5; i++)

                Touchpad Information Technology-XI-XII
          300   T ouchpad In f orma tion T echnology
   297   298   299   300   301   302   303   304   305   306   307