Page 303 - computer science (868) class 11
P. 303

Enter the name of the student: Anjali
                 Enter the name of the student: Deepti
                 Enter the name of the student: Raju
                 Enter the name of the student: Rahul
                 Enter the name of the student: Rakesh
                 Enter the name of the student: Ajay
                 Enter the name of the student: Vijay
                 Enter a name to be deleted:
                 Atul
                 Atul not found



                   Program 4     Create an array of size 10 and fill the array with the factorials of all the numbers between 1
                                 and 10. Then, display the contents of the array.

                   1      class factorial_1to10

                   2      {
                   3          public static void main()

                   4          {
                   5              int i, f = 1;

                   6              int array[ ] = new int[10];
                   7              for(i = 0; i<10; i++)

                   8              {
                   9                  f = f*(i+1);

                  10                  array[i] = f;
                  11              }

                  12              for(i=0; i<10; i++)
                  13                  System.out.println ("Factorial of "+(i+1) + ": " + array[i]);
                  14          }

                  15      }

                 The output of the preceding program is as follows:

                 Factorial of 1: 1
                 Factorial of 2: 2
                 Factorial of 3: 6
                 Factorial of 4: 24
                 Factorial of 5: 120
                 Factorial of 6: 720
                 Factorial of 7: 5040
                 Factorial of 8: 40320
                 Factorial of 9: 362880
                 Factorial of 10: 3628800


                                                                                                                       301
                                                                                                              Arrays   301
   298   299   300   301   302   303   304   305   306   307   308